|
| 29 May 2014 02:03 AM |
elseif key == "f" then if Workspace:FindFirstChild(game.Players.LocalPlayer.Name..'Vehicle').Armed.Value == true then for i,v in pairs(Workspace:FindFirstChild(game.Players.LocalPlayer.Name..'Vehicle').BodyKit:GetChildren()) do wait() if v.Name == "Gun" then wait(0.1) local sound = script.Parent.Blast:Clone() sound.Parent = v sound:Play() local p = Instance.new("Part") p.Name = "Projectile" p.BrickColor = BrickColor.new("Institutional white") p.Reflectance = 0 p.Transparency = 0 p.TopSurface = "Smooth" p.BottomSurface = "Smooth" p.Size = Vector3.new(1, 1, 1) p.CanCollide = false p.formFactor = "Symmetric" local g = p:clone() g.Parent = p local w = Instance.new("Weld") w.Parent = p w.Part0 = p w.Part1 = g local mesh = script.Parent.LightMesh:clone() mesh.Parent = p local mesh = script.Parent.GlowMesh:clone() mesh.Parent = g local s = script.Parent["ProjectileScript"]:Clone() s.Disabled = false s.Parent = p
local bv = Instance.new('BodyVelocity',p) wait() bv.velocity = v.CFrame.lookVector*200 p.Parent=Workspace p.CFrame = v.CFrame wait() sound:Remove() end end else print('I cannot fire the gunz!') end
I want a person to only be able to fire the guns once every 0.3 seconds. I've added debounce in before, but it doesn't work! If anyone could add the debounce in then that would be appreciated, thank you. (For your information, this script works, so don't say it's a problem with the main code) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 29 May 2014 02:07 AM |
Debounce example local Bounce = false function onTouch() if not Bounce then Bounce = true
print("omg u touched me")
wait(5) --debounce time Bounce = false end end script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 02:15 AM |
| I know how it works, but how do I add it to this script that I already have? |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 02:16 AM |
| Because I've tried and it doesn't work. |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 02:44 AM |
| Okay, fine. At least tell me where in the script I should define debounce. |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 02:56 AM |
A debouce is simply a boolen (true or false value) that makes the script to where it will only run one time.
example. while true do game.Workspace.Example.Value+1 -- if this part of the script runs twice you need a debouce script. wait() end
example with debounce Debounce = false
while true do if Debounce == false then debounce = true game.Workspace.Example+1 wait() end end
Any further questions? |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 02:57 AM |
while true do if Debounce == false then debounce = true game.Workspace.Example+1 wait() end Debouce = true end
I made a small error there. |
|
|
| Report Abuse |
|
|
|
| 29 May 2014 03:16 AM |
| I think you have to define what Debounce is because the script reads it like nil |
|
|
| Report Abuse |
|
|