My punch script doesn’t work after resetting character.
What’s wrong and how can I fix?
It’s also local script and inside of StarterPlayerScripts
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local motion = script.Animation
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
repeat wait() until character:FindFirstChild("Humanoid")
local humanoid = character.Humanoid
UserInputService.InputBegan:Connect(function(Input, gameProcessed)
if Input.KeyCode == Enum.KeyCode.E and player.frozen.Value == false and player.holdsword.Value == false and not gameProcessed then
if player.stunned.Value == false then
if player.hitct.Value == false then
if player.hitable.Value == false then
local settruect = ReplicatedStorage:WaitForChild("Settruect")
settruect:FireServer()
local domotion = humanoid:LoadAnimation(motion)
domotion:Play()
local punch = ReplicatedStorage:WaitForChild("Punch")
punch:FireServer(player)
wait(0.5)
local cnghitable = ReplicatedStorage:WaitForChild("Cnghitable")
cnghitable:FireServer(player)
wait(0.2)
local setfalsect = ReplicatedStorage:WaitForChild("Setfalsect")
setfalsect:FireServer()
end
end
end
end
end)