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

I want the player's clothes to be changed through a Remote Event, But it Dont work?

Asked by
ksony 54
5 years ago

Hi, I want the player's clothes to be changed through a Remote Event, so I can enable the FE in my game. But it doesn't work, it doesn't give error or warnings or anything, it just doesn't work. Look at my scripts:

Local script


local PantsId = script.Parent.Parent:FindFirstChild("").Pants.PantsTemplate local ShirtId = script.Parent.Parent:FindFirstChild("").Shirt.ShirtTemplate script.Parent.Bottom.ClickDetector.MouseClick:connect(function(player) game.ReplicatedStorage.Changer:FireServer(PantsId, "p") end) script.Parent.Top.ClickDetector.MouseClick:connect(function(player) game.ReplicatedStorage.Changer:FireServer(ShirtId, "s") end)

Server script


game.ReplicatedStorage.Changer.OnServerEvent:Connect(function(p,Id, PS) if PS == "p" then p.Character.Pants.PantsTemplate = Id elseif PS == "s" then p.Character.Shirt.ShirtTemplate = Id end end)

If there is another simpler way to change the player's clothes and everyone else can see with the FE enabled, please tell me.

2 answers

Log in to vote
0
Answered by
yoyyo75 74
5 years ago
Edited 5 years ago

I'm guessing your trying to get pants and shirts on the first lines but you didn't put it in FindFirstChild("") so when you called that function, it returned nil probably

try this

local PantsId = script.Parent.Parent:FindFirstChild("Pants").Template
local ShirtId = script.Parent.Parent:FindFirstChild("Shirt").Template
0
No, look : https://prnt.sc/pbu5o7 ksony 54 — 5y
0
are the folder's names " "? with a space the8bitdude11 358 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Assuming from your screenshot, it's because they're name isn't blank, it has a space " "

        local PantsId = script.Parent.Parent:FindFirstChild(" ").Pants.PantsTemplate
local ShirtId = script.Parent.Parent:FindFirstChild(" ").Shirt.ShirtTemplate

script.Parent.Bottom.ClickDetector.MouseClick:connect(function(player)
        game.ReplicatedStorage.Changer:FireServer(PantsId, "p")
end)
script.Parent.Top.ClickDetector.MouseClick:connect(function(player)
        game.ReplicatedStorage.Changer:FireServer(ShirtId, "s")
end)



Should Work!

0
it doesnt work ksony 54 — 5y
0
errors? the8bitdude11 358 — 5y

Answer this question