I Tried To Use A Tool That Gives A Accessory To The Player, but it doesn't work? Please Help
Local Script Inside The Tool:
local tool = script.Parent local use = script.Parent.Sounds.Cape local RS = game:GetService("ReplicatedStorage") local Wear = RS:FindFirstChild("SigilWear") local Unwear = RS:FindFirstChild("SigilUnwear") local wearing = false tool.Deactivated:Connect(function() if not wearing then use:Play() Wear:FireServer() wearing = true else use:Play() Unwear:FireServer() wearing = false end end)
The script in server script service:
local RS = game:GetService("ReplicatedStorage") local Wear = RS:FindFirstChild("SigilWear") local Unwear = RS:FindFirstChild("SigilUnwear") local helm = RS:FindFirstChild("Sigil") local plr = game.Players.LocalPlayer local char = ((plr.Character and plr.Character.Parent) and plr.Character) or plr.CharacterAdded:Wait() local human = char:WaitForChild("Humanoid") Wear.OnServerEvent:Connect(function() sigilclone = helm:Clone() human:AddAcessory(sigilclone) end) Unwear.OnServerEvent:Connect(function() sigilclone:Destroy() end)
first things first you cannot use LocalPlayer in a server script as this is a client thing. the way you can do it is pass the character instance through the remote event. local script
local tool = script.Parent local use = script.Parent.Sounds.Cape local RS = game:GetService("ReplicatedStorage") local Wear = RS:FindFirstChild("SigilWear") local Unwear = RS:FindFirstChild("SigilUnwear") local wearing = false local char = game.Players.LocalPlayer.Character.Humanoid tool.Deactivated:Connect(function() if not wearing then use:Play() Wear:FireServer(char) wearing = true else use:Play() Unwear:FireServer(char) wearing = false end end)
server script
local RS = game:GetService("ReplicatedStorage") local Wear = RS:FindFirstChild("SigilWear") local Unwear = RS:FindFirstChild("SigilUnwear") local helm = RS:FindFirstChild("Sigil") Wear.OnServerEvent:Connect(function(player, human) sigilclone = helm:Clone() human:AddAcessory(sigilclone) end) Unwear.OnServerEvent:Connect(function(player) sigilclone:Destroy() end)