Okay, here is an image just now using the script you made
I don’t want the players to have a mess of hats, I just want them to have one hat, also options 1 and 2, there are no errors, so we don’t need to worry about that.
Okay, here is an image just now using the script you made
I don’t want the players to have a mess of hats, I just want them to have one hat, also options 1 and 2, there are no errors, so we don’t need to worry about that.
local Hats = game:GetService(‘ReplicatedStorage’):FindFirstChild(‘CharacterAssets’):FindFirstChild(‘Hats’):GetChildren()
game.Players.PlayerAdded:Connect(function(Player)
if Player then
local Character = Player.Character or Player.CharacterAdded:Wait()
local randomHat = math.random(1,#Hats)
local Chosen = Hats[randomHat]:Clone()
Chosen.Parent = Character:FindFirstChild('Head')
end
end)
The issue in your script is that you don’t delete it from server storage etc. You are duplicating the item.
Looks to me like you’re setting the hat for the StarterCharacter model instead of each player’s character. You could try to set the player’s character’s hats when they spawn in like this
local ServerStorage = game:GetService("ServerStorage")
game:GetService("Players").PlayerAdded:Connect(function(player)
if player.Character then
local Hats = ServerStorage.CharacterAssets:WaitForChild("Hats"):GetChildren()
local Hat = Hats[math.random(1, #Hats)]
Hat.Parent = player.Character
end
player.CharacterAdded:Connect(function(char)
local Hats = ServerStorage.CharacterAssets:WaitForChild("Hats"):GetChildren()
local Hat = Hats[math.random(1, #Hats)]
Hat.Parent = char
end)
end)
Luck can’t be decided it’d be best to clone it so others can have that hat
Yeah this one works exactly how I’d imagine it to work, thank you so much, and I’m very sorry for wasting everyones time on this.
But he didn’t even want to others have the same hat…
Nah it was nice to to break my head a bit. I think i got my code like 10 seconds later oh well
You’re welcome. Glad I could help!
“it doesn’t matter if two players have the same hat”
first read the full post before trying to correct him thanks.
I’m get how I sound here but I’d imagine stating it as the quote says would be the most reliable source on what he want’s as it’s the most recent
I’m not here to argue
By one hat he means he doesn’t want stackable hat’s in the second one you referenced he states my point and the third one is inconsistent
ok! He got what he wanted in the end
All i have to say is use dark mode
Yeah at least he got the script eventually
Idk I kinda prefer light mode on devfourm I do code in darkmode in Robblox studio etc.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.