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

Clothing GUI won't work?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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'

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' kelimeguy 60 — 8y
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. Spongocardo 1991 — 8y
0
Thanks kelimeguy 60 — 8y
Ad

Answer this question