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

Clothing GUI won't work?

Okay so this local script is in a textbutton, which is part of a frame in a screenGUI, which in starterGUI. It is supposed to give clothes when you click it but it isn't doing anything when I test. Anyone know?

script.Parent.MouseButton1Down:connect(function() 
playername = script.Parent.Parent.Parent.Parent.Name 
player = Workspace:FindFirstChild(""..playername.."") 
if player ~= nil then 
  player:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=304161831" -- Pants ID here  
  player:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=304161802"-- Shirt ID here 
end  
end)

1 answer

✓ Accepted answer

One of the big benefits of using LocalScripts is that you can access the LocalPlayer. This can be done using game.Players.LocalPlayer. Whatever variable you set to that will pretty much be set to the player with the Gui inside of him (every player in this instance as the Gui is in StarterGui).

Using this, you can get the Player's model in Workspace using 'game.Players.LocalPlayer.Character' or 'player.Character'. From here you can pretty much do whatever with the player.

e.g. "game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 100"

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Down:connect(function()
	player.Character:FindFirstChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=304161831" -- Pants ID here 
	player.Character:FindFirstChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=304161802"-- Shirt ID here
end)

Edit: Removed extra 'end'

3 comments

0

It still didn't work but there was an output error when I did it: Players.Player.PlayerGui.ClothingGUI.Frame.TextButton.LocalScript:7: ')' expected (to close '(' at line 3) near 'end'

0

He has one more end than he needs to have in the script. Remove the end of line 6 and the script should work.

0

Thanks

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