generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Does this script make any sense? (I tried writing something)

Previous Thread :: Next Thread 
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:19 PM
ok so somebody originally helped me write it but for some reason i keep crashing and loosing the script. Each time this happens it gets more and more distorted...This is what i tried to write on my own...is this just nonsense?

Tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()

script.Parent.Bullet.Part:clone().Parent =Pistol

local Bullet = Instance.new("Part")
Bullet.Locked = true
Bullet.CanCollide = false
Bullet.Anchored = false
Bullet.Size = Vector3.new(.1,.1,.4)

wait(5)

script.Parent.Bullet.findfirstchild.DestroyScript:clone().Parent = Pistol --Destroy script is inside the bullet--

DestroyScript.Enabled=true

end --ill have to figure out how to add velocity later--
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:25 PM
Supposed to clone a union named bullet then copy and enable a script inside the bullet to self destruct in 5 seconds
Report Abuse
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
22 Oct 2014 11:34 PM
OH GOD WHO VOMITED ON THIS FORUM111

Nah it's fine, just put some ends with a closing bracket(or whatever you Americans call it parthesis I don't know eh) at the end of your code, and take advice from the other scripters here that noticed 9001 more errors than me.
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:35 PM
ah so just end it with something like this?

end
end)
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:37 PM
also would this be local or normal script?
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
22 Oct 2014 11:38 PM
BLARGGGGGGGHHHHHHHHHHH

u didn't set up the statement with Pistol in it right (flip it)
and u didn't give Bullet a parent WHAT R U ON
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
22 Oct 2014 11:39 PM
WHAT AM I ON?

the first thing i sed after BLARGH~ isn't right, I meant um you didn't say what Pistol was
Report Abuse
VanillaLight is not online. VanillaLight
Joined: 02 Nov 2013
Total Posts: 834
22 Oct 2014 11:39 PM
He's on the new drug called noob (ayyye) and idk what ur on Mr. Sir.
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:40 PM
The pistol is the tool name, Am i supposed to define it in the scripts??? (nooby at scripting trying to self teach)
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
22 Oct 2014 11:42 PM
You have to define it before you use it
doesn't matter if it's a tool name the script doesn't know that if you don't tell it
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:45 PM
so um Pistol=script.Parent ???
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
22 Oct 2014 11:46 PM
yeah I guess
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
22 Oct 2014 11:55 PM
Tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()

script.Parent=Pistol

script.Parent.Bullet.Part:clone().Parent =Pistol

local Bullet = Instance.new("Part")
Bullet.Locked = true
Bullet.CanCollide = false
Bullet.Anchored = false
Bullet.Size = Vector3.new(.1,.1,.4)

wait(5)

script.Parent.Bullet.findfirstchild.DestroyScript:clone().Parent = Pistol --Destroy script is inside the bullet--

DestroyScript.Enabled=true

end)
end) --ill have to figure out how to add velocity later--



ok there anything else i should change to get this shabby script running?
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
23 Oct 2014 12:01 AM
"script.Parent = Pistol"

is basically

"script.Parent = nil"

what you wanted to do (b/c of context) is:
"Pistol = script.Parent"

Also, you didn't do anything about Bullet having no Parent
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
23 Oct 2014 12:09 AM
wait i had

Pistol = script.Parent

is it right or did you mean something else?
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
23 Oct 2014 12:13 AM
hmm im not sure how i would define the bullet because it goes like this

----Pistol------ *the tool

*Bullet*
*This Script*
scripts
scripts
scripts
parts
parts
parts

i mean it isnt the scripts parent and it isnt its child so what is it???

would i say something like

Pistol.findfirstchild=Bullet ????
Report Abuse
ScrewDeath is not online. ScrewDeath
Joined: 03 Jun 2012
Total Posts: 2700
23 Oct 2014 12:29 AM
I didn't say anything about defining the bullet; I told you to give it a Parent
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
23 Oct 2014 01:40 AM
local Bullet = Instance.new("Part") to local Bullet = Instance.new("Part", workspace)


script.Parent.Bullet.findfirstchild.DestroyScript:clone().Parent = Pistol --Destroy script is inside the bullet--

to

Bullet:Destroy()

it's way less complicated to destroy the bullet within the same script rather than using another script to clone a script that will destroy it. You may also delete the DestroyScript completely. You did butcher that clone line a bit by the way.

there's a few more errors too but I don't feel like looking through to see what was already addressed and what was not.
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
23 Oct 2014 09:29 AM
Alright thanks alot guys im trying to self teach but scripting helpers is really how i learn :P.

It says tool (line one) is an unknown global

and Pistol (line 4) global is only used in the enclosing function;Consider changing it to local


What should i do to fix those? (Thanks for bearing with me here)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Oct 2014 09:51 AM
Define tool
Put local before Pistol on line 4
Report Abuse
sycips is not online. sycips
Joined: 21 Mar 2011
Total Posts: 1368
23 Oct 2014 09:54 AM
Tool.Equipped:connect(function(Mouse) --Tool isn't defined
Mouse.Button1Down:connect(function() --Try using another .Activated

script.Parent.Bullet.Part:clone().Parent =Pistol --Pistol is not defined

local Bullet = Instance.new("Part") --Why are you creating a second bullet?
Bullet.Locked = true
Bullet.CanCollide = false
Bullet.Anchored = false
Bullet.Size = Vector3.new(.1,.1,.4)
--The bullet isn't in workspace now, which means you won't see it...

wait(5) --Far easier way of doing this...

script.Parent.Bullet.findfirstchild.DestroyScript:clone().Parent = Pistol --Wrong use of ':FindFirstChild()'. Probably don't need a script to destroy a bullet/part... Pistol isn't defined.
--Destroy script is inside the bullet--

DestroyScript.Enabled=true --DestroyScript isn't defined.

--Missing 'end'
--Missing 'end)'

Alright, that were all the errors I could find. Now you know what's wrong at the first script. But I guess you'd like to know the better script too. So here is how I should do it:

Tool = script.Parent --Defining 'Tool'

Tool.Activated:connect(function() --.Activated is an event which calls the function when the player has the tool equipped AND the player is clicking mousebutton1 (left)

local Bullet = Instance.new("Part",Tool) --The second argument of 'Instance.new' tells the function to 'parent' the new bullet/part/object to 'Tool' (the pistol)
Bullet.Locked = true
Bullet.CanCollide = false
Bullet.Anchored = false
Bullet.Size = Vector3.new(.1,.1,.4)

game:GetService("Debris"):AddItem(Bullet,5) --The game automaticly removes 'Bullet' in 5 seconds.

end)

Now this script isn't done yet. You need to position the bullet, give to bullet a speed AND you need an event called .Touched to damage players. If you like my explaination, I'll tell you more. Also, if you don't understand anything, please ask me :)

~sycips~
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
23 Oct 2014 09:57 AM
Alright wonderful. anything else i need to fix before this will actually work and duplicate the bullets for me?

local Tool=script.Parent
Tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()

local Pistol=script.Parent

script.Parent.Bullet.Part:clone().Parent =Pistol

local Bullet = Instance.new("Part")
Bullet.Locked = true
Bullet.CanCollide = false
Bullet.Anchored = false
Bullet.Size = Vector3.new(.1,.1,.4)

wait(5)

script.Parent.Bullet.findfirstchild.DestroyScript:clone().Parent = Pistol --Destroy script is inside the bullet--

DestroyScript.Enabled=true

end)
end) --ill have to figure out how to add velocity later--
Report Abuse
Wolfhead666 is not online. Wolfhead666
Joined: 13 Jan 2010
Total Posts: 881
23 Oct 2014 10:01 AM
sycips Alright thanks man! ill try it out. Thanks for the help everyone
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image