#[SOLVED] how to add an attribute to the players character?
1 messages · Page 1 of 1 (latest)
That adds it to the character not the player
As Suphi said this is adding it to the Character, not the Player in Players, the Character is stored in workspace, if you want to retrieve the value off of the character you would need the model from workspace, else it's just
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player:SetAttribute("Hiding", true)
end
And how do i add an attribute to the character?
how to add an attribute to the players character?
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
Character:SetAttribute("Hiding", true)
end
and whats the differences between my code and yours?
I wouldn't be able to tell you to be honest, your code works just fine if that's what you're worried about.
Are you using :GetAttribute() on the model or the player? The model is under workspace, that's what Player.Character is, player is a child of game:GetService("Players")
yeah
im using :SetAttribute() whenever player joins and i added the print() statement to check
and there's no print in the output
Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
character:SetAttribute("Hiding", true)
print("Set the attribute to the player:" .. character.Name)
end)
You don't see the print line in the output window? And you're sure you have the correct window open?