Local script :
local Player = game:GetService("Players") local rp = game:GetService("ReplicatedStorage") local KiritosSword = rp:WaitForChild("KiritosSword") local tool = script.Parent local UIS = game:GetService("UserInputService") local debounce = false local cooldown = 1 UIS.InputBegan:Connect(function(input,isTyping) if isTyping then return elseif input.KeyCode == Enum.KeyCode.F and debounce == false then debounce = true KiritosSword:FireServer() end end) KiritosSword.OnClientEvent:Connect(function() wait(cooldown) debounce = false end)
And Script
local rp = game:GetService("ReplicatedStorage") local KiritosSword = rp:WaitForChild("KiritosSword") local Animation = game.Workspace.Animations:WaitForChild("Swing") -- Find the animation local tool = script.Parent local Blade = script.Parent:WaitForChild("Blade") local Particle1 = Blade:WaitForChild("Lightning1") local Particle2 = Blade:WaitForChild("Lightning2") local Particle3 = Blade:WaitForChild("ParticleEmitter") KiritosSword.OnServerEvent:Connect(function(Player) local Character = Player.Character local Humanoid = Character:FindFirstChild("Humanoid") local Swing = Humanoid:LoadAnimation(Animation) Swing:Play() KiritosSword:FireClient(Player) wait(1) Particle1.Enabled = true Particle2.Enabled = true Particle3.Enabled = true end)
Okay so, animations automatically replicate to the server so there's no need to play them on the server.
Also, nest the UserInputFunction in the tool's equipped function like so:
local UserInputService = game:GetService("UserInputService") local Debounce = false local InputFunction script.Parent.Equipped:Connect(function() InputFunction = UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent) -- in your case GameProcessedEvent is IsTyping if GameProcessedEvent or debounce == true then return end if Input.KeyCode = Enum.KeyCode.F and debounce == false then debounce = true -- rest of your code end end) -- rest of your code end)
And disconnect the function on tool unequip so it doesn't keep running on input.
script.Parent.Unequipped:Connect(function() InputFunction:Disconnect() end)
https://gyazo.com/e15299a6b6e9850e0d92478c10e1b9e4
heres how it looks