|
| 14 Jan 2013 08:35 PM |
I want to modify the original roblox rocket launcher by making it have to reload. Similar to the six shooter, after 6 shots, it would point a direction (Maybe down or sideways) and have to wait a few seconds before another 6 shots could be fired. I attemped to copy this line of code and failed: (What can i say, i'm a noobie to scripting)
reloading = reloading + 1 if reloading >= 6 then if reloadSound ~= nil then reloadSound:Play() end reloading = 0 Tool.GripUp = Vector3.new(0,-0.5,1) wait(0.5) Tool.GripUp = Vector3.new(0,0,1) end
wait(reload) gunOut() wait(reload)
enabled = true
end
I would be happy to know how this works because i'm trying to make my game as authentic as possible. |
|
|
| Report Abuse |
|
harryx
|
  |
| Joined: 25 Oct 2008 |
| Total Posts: 3209 |
|
|
| 15 Jan 2013 06:14 AM |
I'll try to go through it in chunks.
reloading = reloading + 1 if reloading >= 6 then
Each time the gun fires, the first line adds 1 to the value 'reloading', as to keep count of when it should reload. In the next line it checks if the value has reached six, and then if it does, continues on to the next section.
if reloadSound ~= nil then reloadSound:Play() end
This chunk is for playing the reloading sound. It first makes sure that the sound exists, then plays it.
reloading = 0 Tool.GripUp = Vector3.new(0,-0.5,1) wait(0.5) Tool.GripUp = Vector3.new(0,0,1) end
Firstly, it resets the value of 'reloading'. Then it changes the position of the tool so it looks as if it is reloading, waits half a second and then returns to its original position.
wait(reload) gunOut() wait(reload)
I would have to see the rest of the script to give you a detailed explanation, but it looks like it waits an allotted time, calls the function gunOut() and then waits some more.
enabled = true end
It changes the value of 'enabled' to true and closes the if statement we had at the start.
Hope this helped you. |
|
|
| Report Abuse |
|