01 | local Hat = game.ReplicatedStorage:WaitForChild( "Hat_1" ) |
02 | local Player = game.Players.LocalPlayer |
03 | local Char = Player.Character |
04 | local Humanoid = Char:WaitForChild( "Humanoid" ) |
05 |
06 | function GetPlayers() |
07 | for _,v in pairs (game.Players:GetChildren()) do |
08 | if v.Name = = "Player1" then |
09 | Humanoid:AddAccessory(Hat) |
10 | end |
11 | end |
12 | -- print ("No errors found.") |
13 | end |
14 |
15 | GetPlayers() |
This is a LocalScript. I'm almost certain it has something to do with an if statement
. I also know that functions repeat but apparently not this one.
UPDATE
1 | local Hat = game.ReplicatedStorage:WaitForChild( "Hat_1" ) |
2 | local Player = game.Players.LocalPlayer |
3 | local Char = Player.Character |
4 | local Humanoid = Char:WaitForChild( "Humanoid" ) |
5 |
6 | if Player.Name = = "Player1" then |
7 | Humanoid:AddAccessory(Hat) |
8 | print ( "Fluid." ) |
9 | end |
So apparently you can't reset the function AddAccessory()
. I've tried cloning with the Add()
function and it did not work. I have been told that I can "repeat" this by adding the accessory every time they respawn however I don't know how to go about this. Any help?
This gives the hat to you so you can wear it, works perfectly fine.
------- VARIABLES -------
01 | local players = game:GetService( "Players" ); |
02 | local priveliged_players = { "Player1" , "KingLoneCat" , "Somebody" , "greatneil80" } |
03 | local rs = game:GetService( "ReplicatedStorage" ); |
04 | ------- VARIABLES ------- |
05 |
06 | ------- FUNCTIONS ------- |
07 | players.PlayerAdded:Connect( function (plr) |
08 | for _,v in next , priveliged_players do |
09 | if plr.Name = = v then |
10 | plr.CharacterAdded:Connect( function (char) |
11 | local hats = rs:WaitForChild( "Hats" ):GetChildren(); |
12 | for _,v in next , hats do |
13 | local hat = v:Clone(); |
14 | hat.Parent = char; |
15 | end |
16 | end ) |
17 | end |
18 | end |
19 | end ) |