local Hat = game.ReplicatedStorage:WaitForChild("Hat_1") local Player = game.Players.LocalPlayer local Char = Player.Character local Humanoid = Char:WaitForChild("Humanoid") function GetPlayers() for _,v in pairs(game.Players:GetChildren()) do if v.Name == "Player1" then Humanoid:AddAccessory(Hat) end end -- print ("No errors found.") end 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
local Hat = game.ReplicatedStorage:WaitForChild("Hat_1") local Player = game.Players.LocalPlayer local Char = Player.Character local Humanoid = Char:WaitForChild("Humanoid") if Player.Name == "Player1" then Humanoid:AddAccessory(Hat) print ("Fluid.") 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 -------
local players = game:GetService("Players"); local priveliged_players = {"Player1", "KingLoneCat", "Somebody", "greatneil80"} local rs = game:GetService("ReplicatedStorage"); ------- VARIABLES ------- ------- FUNCTIONS ------- players.PlayerAdded:Connect(function(plr) for _,v in next, priveliged_players do if plr.Name == v then plr.CharacterAdded:Connect(function(char) local hats = rs:WaitForChild("Hats"):GetChildren(); for _,v in next, hats do local hat = v:Clone(); hat.Parent = char; end end) end end end)