Alright, I’m scripting a uniform GUI that allows you to select a uniform based on your rank in the main group. This part, to the best of my knowledge, is working. The button works and the GUI opens, but the problem is that I scripted one of the buttons, the HR button. The hierarchy and script for it is below.
local hr = script.Parent.Parent.StarterGui.ScreenGui.UniformGUI.HR
hr.MouseButton1Click:Connect(function()
game.Players.PlayerAdded:Connect(function(plr)
print("hi")
plr:WaitForChild("Character").Shirt.ShirtTemplate.Value = 513567320
print("hi")
plr:WaitForChild("Character").Pants.PantsTemplate.Value = 513570472
print("hi")
end)
end)
I could really use some help as it isn’t even printing the first “hi.”
catIoaf
(qolop)
June 26, 2022, 5:05am
2
When the player loads in, GUIs are cloned to their StarterPlayerGUIs. The GUI you want to reference is not the one in startergui, but the one in the starterplayergui. You should also switch to using localscripts and remoteevents to handle these kinds of requests.
1 Like
Alright, I tried to implement this but this new code still isn’t working and I’m getting no “hi’s.”
game.Players.PlayerAdded:Connect(function(plr)
local hr = plr.PlayerGui.ScreenGui.UniformGUI.HR
hr.MouseButton1Click:Connect(function()
print("hi")
plr:WaitForChild("Character").Shirt.ShirtTemplate.Value = 513567320
print("hi")
plr:WaitForChild("Character").Pants.PantsTemplate.Value = 513570472
print("hi")
end)
end)
Also I’ll stick with how I’m doing it already so far as I’m not that advanced and will probably end up breaking more stuff, but thanks for the advice.
catIoaf
(qolop)
June 26, 2022, 5:12am
4
I think it would be better to add a localscript under the HR button. Copying this should work:
script.Parent.MouseButton1Click:Connect(function()
print("hi")
plr:WaitForChild("Character").Shirt.ShirtTemplate.Value = 513567320
print("hi")
plr:WaitForChild("Character").Pants.PantsTemplate.Value = 513570472
print("hi")
end)
However, this won’t replicate to clients. You should have a listener on the server to change your clothing template.
1 Like
Alright at least I got a console output this time, but;
Also in the script you gave me, “plr” isn’t defined.
catIoaf
(qolop)
June 26, 2022, 5:17am
6
My bad. You should define the plr, in this case, it should be game.Players.LocalPlayer.Character
1 Like
This is the new one;
local plr = game.Players.LocalPlayer.Character
script.Parent.MouseButton1Click:Connect(function(plr)
print("hi")
plr:WaitForChild("Character").Shirt.ShirtTemplate.Value = 513567320
print("hi")
plr:WaitForChild("Character").Pants.PantsTemplate.Value = 513570472
print("hi")
end)
catIoaf
(qolop)
June 26, 2022, 5:20am
8
You don’t need waitforchild anymore. It’s already defined at the top.
1 Like
Yep, I removed it just before you replied, but now this. This is why I haven’t changed my group title to programmer yet
local plr = game.Players.LocalPlayer.Character
script.Parent.MouseButton1Click:Connect(function()
print("hi")
plr.Character.Shirt.ShirtTemplate.Value = 513567320
print("hi")
plr.Character.Pants.PantsTemplate.Value = 513570472
print("hi")
end)
catIoaf
(qolop)
June 26, 2022, 5:23am
10
No, I meant removing the entire waitforchild so it becomes like this:
plr.Shirt.ShirtTemplate.Value = 513567320
1 Like
I tried to do tonumber() but it still didn’t wanna cooperate
local plr = game.Players.LocalPlayer.Character
script.Parent.MouseButton1Click:Connect(function()
print("hi")
plr.Shirt.ShirtTemplate.Value = tonumber(513567320)
print("hi")
plr.Pants.PantsTemplate.Value = tonumber(513570472)
print("hi")
end)
catIoaf
(qolop)
June 26, 2022, 5:30am
12
plr.Shirt.ShirtTemplate = 513567320
Alright thanks this worked, but it just took my shirt and pants off, it didn’t replace them.
catIoaf
(qolop)
June 26, 2022, 5:40am
14
try
plr.Shirt.ShirtTemplate = "rbxassetid://" .. 513567320
1 Like