|
How could I script it so when you press a GUI Button, it clones a hat to the player? |
|
|
--script is a local script, placed in the textbutton.
wait(2)
script.Parent.MouseButton1Click:connect(function()
plr = game.Players.LocalPlayer
h = hat:Clone() --lets say you defined hat as the hat you wanted to clone.
h.Parent = plr.Character
end |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
@Silver
I think that would work but its kinda messy code.
I think you should learn about local variables
Also if you only use something once you shouldn't set a variable to it |
|
FunseJoin Date: 2012-06-11 Post Count: 7887 |
Best you weld it, because noobs can press =. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
@Roblox
How is it being new to remove a hat? |
|
|
@128GB
for hat, I meant that he would save hats under it. Like, say the hat is in the lighting, I meant change "hat" to game.Lighting.HatNameHere
Also, I haven't really used local varuables that often, I suppose I should start :/ |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
I was talking about this
plr = game.Players.LocalPlayer
You should use local variables anytime you can |
|
|
k den
and I usually use game.Player.LocalPlayer very often in every script, so I save a bit of typing. Though you are right, I didn't need that. Just old habits (when I was a beginner, I used to think you needed to save game.Players.LocalPlayer in a variable. Of course, I know better now, but they're habits) |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
I still suggest using local variables whenever possible (Its really always possible)
Do you know how to use them? |
|
|
My hat isn't actually a "hat", it's a part. |
|
|
Oh...then you would need to weld it...
w = Instance.new("Weld")
w.Part0 = hat
w.Part1 = game.Players.LocalPlayer.Character.Head
w.C0 = game.Players.LocalPlayer.Character.Head.Position
pehh...thats all I got... I'm no good with welding. I'll learn though. |
|