Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Wont refresh when the player resets?

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?

1 comment

1

Why would you want to do this with all the players? Why just the specific player?

1 answer

✓ Accepted answer

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)

3 comments

0

upvote the question 2 bb :)

0

coooooooooooool

0

yeaaaaaaaaaaaaaaaaa

This discussion is preserved as it was. New answers, comments, and votes are closed.