Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Acessory Not Equiping With Tool ?

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)

1 comment

0

Put the script in the tool.

1 answer

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)

3 comments

0

if you have any problems comment below if this is the answer make sure to mark it as the answer for other people

0

this just doesnt worked

0

hmm any errors?

This discussion is preserved as it was. New answers, comments, and votes are closed.