Hi! I started making great progress on my game, and I completed this bomb script, but there's one thing that I haven't experienced ever with remote events. My debounce wont work. I looked at tons of other people and their ways of doing it, but it was exactly like the way I did it. I don't know if this is on the Button scripts end or if its on the Attack scripts end. It creates 2 bombs instead of one, which means double damage! Please help!
This scripts debounce won't work. Server Script, in StarterCharacterScripts.
local part = game.ReplicatedStorage.ClassData.Bloxxer.BloxxerSword:Clone() local P = script.Parent local fire = game.ReplicatedStorage.MoveSetFires local A = P.ATK local cda = false local AF = fire.Attack local A1 = P.AB1 local A1F = fire.AB1 local A2 = P.AB2 local A2F = fire.AB2 local RJ = P.REJ local RJF = fire.Rejuvinate local CORE = P.BTZ local CF = fire.Core local Attackcd = false local AtCD = .8 A1.Changed:Connect(function(v) print(v) end) local function createhitbox(position, size1, size2, size3, damage, tim, offset, plr, ray, direction) local hit = Instance.new("Part") hit.Size = Vector3.new(size1,size2,size3) hit.Color = Color3.new(200,0,0) hit.Transparency = .6 hit.CFrame = position.CFrame hit.Orientation = Vector3.new(0, 0, 0) hit.CanCollide = false hit.Parent = workspace if ray == true then end local destroy = coroutine.create(function() wait(tim) if hit then hit:Destroy() end end) coroutine.resume(destroy) hit.Touched:Connect(function(h) if h.Parent ~= plr.Character then if h.Parent.Humanoid then local humanoid = h.Parent.Humanoid or h.Parent:FindFirstChildOfClass("Humanoid") print(h) humanoid.Health = humanoid.Health - damage hit:Destroy() end end end) end print("okok") A1F.OnServerEvent:Connect(function(player) wait(.1) print(cda) if cda == false then cda = true if player then --the hitbox local bomb = Instance.new("Part") bomb.Name = "Projectile" bomb.Shape = Enum.PartType.Ball bomb.Color = Color3.new(0,0,0) bomb.Size = Vector3.new(1.7, 1.7, 1.7) bomb.Transparency = .2 bomb.CFrame = player.Character.HumanoidRootPart.CFrame bomb.Parent = workspace --local bv = Instance.new("BodyForce", bomb) bomb.CanCollide = false bomb.Velocity = player.Character.UpperTorso.CFrame.lookVector * 25 wait(.1) bomb.CanCollide = true wait(2) createhitbox(bomb, 10.95, 10.95, 10.95, 15, .5, 0, player, false, nil) bomb:Destroy() --createhitbox(3.1, 2.45, 7.25, 6, .1, -8, player, false, nil) cda = false end end end)
This script works and the prints tell me this isn't the problem. Local script, in StarterCharacterScripts.
wait(5) local UserInputService = game:GetService("UserInputService") local player = game.Players.LocalPlayer local char = player.Character local mouse = player:GetMouse() local P = script.Parent local fire = game.ReplicatedStorage.MoveSetFires local A1 = P.AB1 local A1F = fire.AB1 local A2 = P.AB2 local A2F = fire.AB2 local RJ = P.REJ local RJF = fire.Rejuvinate local CORE = P.BTZ local CF = fire.Core local function click(move,cd) print(move,cd) move:FireServer() wait(cd) end UserInputService.InputBegan:Connect(function(Input, Gamestuff) if Gamestuff then return end --AB1 if Input.KeyCode == Enum.KeyCode.Q then if A1.Value == false then A1.Value = true click(A1F,4) A1.Value = false end end --Ab2 if Input.KeyCode == Enum.KeyCode.E then if A2.Value == false then A2.Value = true end end end)
So I had a "duh" moment. Apparently, it fired twice because the fire was in Replicated storage, and that would fire for every player, not just the player in question.