Keybind does not work in multiplayer

I made a hook projectile, and when it attaches to something it parents to your character and is named your username, to get rid of it when it is in your attached state you press “R” and it finds the part in your character and deletes it. works fine alone but it multiplayer it does not work.

script:

local event = script.Parent.RPressed
local replicatedStorage = game:GetService("ReplicatedStorage")

event.OnServerEvent:Connect(function(Player,Action)
	local Folder = Player:WaitForChild("NumberOfHooks")
	local IntValue = Folder:WaitForChild("Amount")
if IntValue.Value == 1 then
	if Action == "R" then
			
		local Hook = Player.Character:FindFirstChild(Player.Name)
		Hook:Destroy()
		
		local Folder = Player:WaitForChild("NumberOfHooks")
		local IntValue = Folder:WaitForChild("Amount")
		
		IntValue.Value = IntValue.Value - 1

		end
	end
end)

I don’t know if that is the solution but try checking if there is a hook at first, if there is, delete the old hook.

I fixed it, Multiple would clone in so I just added a return function to cancel it if one already existed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.