Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Acessory Not Equiping With Tool ?

Asked by 4 years ago

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:

01local tool = script.Parent
02local use = script.Parent.Sounds.Cape
03local RS = game:GetService("ReplicatedStorage")
04local Wear = RS:FindFirstChild("SigilWear")
05local Unwear = RS:FindFirstChild("SigilUnwear")
06local wearing = false
07 
08 
09tool.Deactivated:Connect(function()
10    if not wearing then
11        use:Play()
12        Wear:FireServer()
13        wearing = true
14    else
15        use:Play()
16        Unwear:FireServer()
17        wearing = false
18    end
19end)

The script in server script service:

01local RS = game:GetService("ReplicatedStorage")
02local Wear = RS:FindFirstChild("SigilWear")
03local Unwear = RS:FindFirstChild("SigilUnwear")
04local helm = RS:FindFirstChild("Sigil")
05local plr = game.Players.LocalPlayer
06local char = ((plr.Character and plr.Character.Parent) and plr.Character) or plr.CharacterAdded:Wait()
07local human = char:WaitForChild("Humanoid")
08 
09Wear.OnServerEvent:Connect(function()
10    sigilclone = helm:Clone()
11    human:AddAcessory(sigilclone)
12end)
13 
14Unwear.OnServerEvent:Connect(function()
15    sigilclone:Destroy()
16end)
0
Put the script in the tool. DiamondComplex 285 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

01local tool = script.Parent
02local use = script.Parent.Sounds.Cape
03local RS = game:GetService("ReplicatedStorage")
04local Wear = RS:FindFirstChild("SigilWear")
05local Unwear = RS:FindFirstChild("SigilUnwear")
06local wearing = false
07local char = game.Players.LocalPlayer.Character.Humanoid
08 
09tool.Deactivated:Connect(function()
10    if not wearing then
11        use:Play()
12        Wear:FireServer(char)
13        wearing = true
14    else
15        use:Play()
16        Unwear:FireServer(char)
17        wearing = false
18    end
19end)

server script

01local RS = game:GetService("ReplicatedStorage")
02local Wear = RS:FindFirstChild("SigilWear")
03local Unwear = RS:FindFirstChild("SigilUnwear")
04local helm = RS:FindFirstChild("Sigil")
05 
06Wear.OnServerEvent:Connect(function(player, human)
07    sigilclone = helm:Clone()
08    human:AddAcessory(sigilclone)
09end)
10 
11Unwear.OnServerEvent:Connect(function(player)
12    sigilclone:Destroy()
13end)
0
if you have any problems comment below if this is the answer make sure to mark it as the answer for other people marsdonh 36 — 4y
0
this just doesnt worked MacGames007 114 — 4y
0
hmm any errors? marsdonh 36 — 4y
Ad

Answer this question