Hi, i working on my combat system but when i respawn 2nd times my script won’t get remote event that fire from local script
Here the video :
Here my local script where it fire remote
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local inputBeganConnection
local inputEndedConnection
local char = player.Character or player.CharacterAdded:Wait()
local EquipSword = char:WaitForChild("EquipSword")
local UserInputService = game:GetService("UserInputService")
local Attack = char:WaitForChild("Attack")
local block = char:WaitForChild("Block")
local unblock = char:WaitForChild("UnBlock")
local function onInputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.E then
print("test")
EquipSword:FireServer()
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
Attack:FireServer()
end
end
UserInputService.InputBegan:Connect(onInputBegan)
inputBeganConnection = UserInputService.InputBegan:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.F then
block:FireServer(inputBeganConnection)
end
end)
inputEndedConnection = UserInputService.InputEnded:Connect(function(inputObject, gameProcessed)
if inputObject.KeyCode == Enum.KeyCode.F then
unblock:FireServer(inputEndedConnection)
end
end)
**Here part of my equip sword script Where it get event from fired remote **
function EquipSword()
local hum = char:FindFirstChild("Humanoid")
local cloned1 = false
local cloned2 = false
local anim = hum:LoadAnimation(script.EquipKatana)
local anim2 = hum:LoadAnimation(script.UnEquipKatana)
if equipsword == false then
if cloned1 == true then
return
end
if respawned == true then
anim2:Play()
end
canSwing = false
if anim2.IsPlaying then
anim2.Stopped:wait()
end
unequipsound:Play()
weapon.Transparency = 0
weapon.Parent = char
weld.Parent = weapon
weld.Part0 = weapon
weld.Part1 = char.Torso
weld.C0 = weld.Part0.Attachment.CFrame
weld.C1 = weld.Part1.BodyFrontAttachment.CFrame * CFrame.new(-1.1, -0.5, -0.7) * CFrame.Angles(-70.5,math.rad(-180),math.rad(-180))
weaponsheat.Transparency = 1
equipsword = true
elseif equipsword == true then
if cloned2 == true then
return
end
anim:Play()
equipsound:Play()
weaponsheat.Transparency = 0
weaponsheat.Parent = char
weld2.Parent = weaponsheat
weld2.Part0 = weaponsheat
weld2.Part1 = char:FindFirstChild("Right Arm")
weld2.C0 = weld2.Part0.Attachment.CFrame
weld2.C1 = weld2.Part1.RightGripAttachment.CFrame * CFrame.new(0, 0, 0) * CFrame.Angles(70.7,math.rad(180),math.rad(180))
weapon.Transparency = 1
canSwing = true
equipsword = false
end
end
char.EquipSword.OnServerEvent:Connect(EquipSword)
equipsword = false
EquipSword()
respawned = true