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 3 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:

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)
0
Put the script in the tool. DiamondComplex 285 — 3y

1 answer

Log in to vote
0
Answered by 3 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

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)
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 — 3y
0
this just doesnt worked MacGames007 114 — 3y
0
hmm any errors? marsdonh 36 — 3y
Ad

Answer this question