I have an npc that gives you the ability to press e and you throw out a fireball. When one player in the server alone has the ability to do so it spawns one fireball but when two players have the ability when e is pressed two fireballs spawn, and so on with more people.
This script is the keypress and cooldown and stuff.
local RS = game:GetService("ReplicatedStorage") local remote = RS:WaitForChild("Fireballe") local plr = game.Players.LocalPlayer local mouse = game.Players.LocalPlayer:GetMouse() local animation = plr.Character:WaitForChild("Humanoid"):LoadAnimation(remote:WaitForChild("Hit")) local cooldown = false mouse.KeyDown:Connect(function(key) if cooldown == true then return end if key == "e" then cooldown = true animation:Play() wait(.2) remote:FireServer() wait(3) cooldown = false end end)
This script is the fireball.
local RS = game:GetService("ReplicatedStorage") local remote = RS:WaitForChild("Fireballe") local tweenservice = game:GetService("TweenService") remote.OnServerEvent:Connect(function(plr) local fireball = game.ReplicatedStorage.Fireball.Part:Clone() fireball.Parent = workspace game.Debris:AddItem(fireball,3) fireball.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 15 tweenservice:Create(fireball,TweenInfo.new(3,0,0),{CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 70,Transparency = 1},Enum.EasingStyle.Quint,Enum.EasingDirection.Out):Play() local alreadytouched = false fireball.Touched:Connect(function(hit) if alreadytouched == true then return end if hit.Parent.Name == plr.Name then return end if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 20 for i = 1,#hit.Parent:GetChildren() do if hit.Parent:GetChildren()[i]:IsA("Part") or hit.Parent:GetChildren()[i]:IsA("MeshPart") then local fireparticle = game.ReplicatedStorage.Fireball.Fire:Clone() fireparticle.Parent = hit.Parent:GetChildren()[i] game.Debris:AddItem(fireparticle,6) alreadytouched = true end end for i = 1,6 do hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 3 wait(1) end end end) wait(2.3) alreadytouched = true end)
try changing if cooldown == true then return end
to if not cooldown then
in line 9 of the cooldown script