Your indenting style and all of those seemingly useless functions are really confusing me.
Line 15 will error out - :FindFirstChild() tries to FIND the given child in a given object. Returns nil if it doesn't.
Line 23 will error out - hat will not be found anywhere. You might have the script intend to find it in line 5, but, unfortunately, it can only be accessed in the "if" statement in the RegisterPlayer() function since it is a local variable.
Notice that there are two links in "local."
What you wanted is a relatively easy feat to do, and it can be accomplished by around 12 lines or so.
Ignoring all of those functions above line 21, you might need to add the hat spawning code to let people receive their hat when they first get in the game. To do so, you have to put the code in between line 21 and line 22 in your case.
game.Players.PlayerAdded:connect(function (player)
player.CharacterAdded:connect(function (character)
The reason why you have to have some code before line 22 in order for it to work is because the .CharacterAdded event will not fire until after the first character is dead. I don't know why this happens. But it does.
:IsInGroup: Checks if the player is in a group. Returns true if it is. Accepts a set of integers that represents the group's ID.
EXAMPLE:
if game.Players.LocalPlayer:IsInGroup(7) then
print("true")
else
print("false")
end
game:GetService("InsertService"):LoadAsset(): Loads the given asset with a valid ID.
EXAMPLE:
local Item = game:GetService("InsertService"):LoadAsset(23220518)
Item.Parent = workspace
Now, all you have to do is try and utilize the two special terms I just mentioned.
Then try and replicate the code so that it is in two places:
Try and use the examples to help you in your scripting process.
NOTE:
To have characters wear a hat, just parent the hat object with the Handle basepart to the character itself. You don't have to do any special welding thing, a giver or anything like that.
2 comments
i dont understand @ Redbullusa
What do you not understand?