I've found a temporary solution for a previous for a previous problem but a new issue has arisen. The tool does what I want it to, but the problem is that it does this even when the tool isn't equipped, which is an issue for obvious problems.
Here is the 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)
And the local script:
local Player = game.Players.LocalPlayer local mouse = Player:GetMouse() mouse.Button1Down:Connect(function() script.Parent.RemoteEvent:FireServer() end)
The tool as it is in the workspace:
Tool
Script & Local Script & Remote Event
[Inside Script] Mask & Hood (Accessories)
I've tried a few different things but whatever I do either seems to break it or not change anything. Any and all help is appreciated.
I think you forgot to fire if ISEquipped is true or false in the Server, try this:
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 ISEquipped == true 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 else print("Tool is not equipped! Equip in order to work.") end end end)
If there are mistakes, lemme know. ????
Finally found the solution! Here it is:
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 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() else end end end end)
Hope this will be helpful to anyone in the future!