|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Oct 2014 11:35 PM |
ah so just end it with something like this?
end end) |
|
|
| Report Abuse |
|
|
|
| 22 Oct 2014 11:37 PM |
| also would this be local or normal script? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Oct 2014 11:39 PM |
| He's on the new drug called noob (ayyye) and idk what ur on Mr. Sir. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 22 Oct 2014 11:45 PM |
| so um Pistol=script.Parent ??? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 23 Oct 2014 12:09 AM |
wait i had
Pistol = script.Parent
is it right or did you mean something else? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 23 Oct 2014 10:01 AM |
| sycips Alright thanks man! ill try it out. Thanks for the help everyone |
|
|
| Report Abuse |
|
|