What I’m trying to do is make a tool that will add/destroy these two certain accessories.
The problem, however, is that even when the tool is unequipped, it will continue to add/destroy these accessories when the mouse is clicked. I’ve tried editing the script to detect when the tool is equipped but it doesn’t seem to work. I’ve even tried getting rid of the local script and remote event, but that breaks it.
Any and all help is appreciated with this strange issue.
Script:
local ISEquipped = false
local Mask = script:WaitForChild("Mask")
local Hood = script:WaitForChild("Hood")
script.Parent.Equipped:Connect(function()
ISEquipped = true
end)
script.Parent.Unequipped:Connect(function()
ISEquipped = false
end)
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
if plr.Character:WaitForChild("Humanoid") then
if plr.Character:FindFirstChild("Mask") == nil then
Mask:Clone().Parent = plr.Character
Hood:Clone().Parent = plr.Character
elseif plr.Character:FindFirstChild("Mask") then
plr.Character.Mask:Destroy()
plr.Character.Hood:Destroy()
end
end
end)
Local Script:
local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
mouse.Button1Down:Connect(function()
script.Parent.RemoteEvent:FireServer()
end)
you made the ISEquipped but u didnt check if it’s true or false
so change the OnServerEvent function to
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
if ISEquipped then
if plr.Character:WaitForChild("Humanoid") then
if plr.Character:FindFirstChild("Mask") == nil then
Mask:Clone().Parent = plr.Character
Hood:Clone().Parent = plr.Character
elseif plr.Character:FindFirstChild("Mask") then
plr.Character.Mask:Destroy()
plr.Character.Hood:Destroy()
end
end
end
end)
local Tool = script.Parent
Tool.Activated:Connect(function()
script.Parent.RemoteEvent:FireServer()
end)
and The ServerScript to
local Mask = script:WaitForChild("Mask")
local Hood = script:WaitForChild("Hood")
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
if plr.Character:WaitForChild("Humanoid") then
if plr.Character:FindFirstChild("Mask") == nil then
Mask:Clone().Parent = plr.Character
Hood:Clone().Parent = plr.Character
elseif plr.Character:FindFirstChild("Mask") then
plr.Character.Mask:Destroy()
plr.Character.Hood:Destroy()
end
end
end)
Does your tool have RequiresHandle enabled? Equip and Unequip events won’t fire without a Handle unless you’ve turned that setting off, and it’s on by default.
Man, it was really that simple lol.
So, combined with @msix29 first reply and your input, I actually got it to work as intended. All I had to do was change the script a bit, add a part, and name it Handle. Thanks to both of you for the help.