NinjoOnline
(NinjoOnline)
September 12, 2021, 1:26pm
#1
I have the server set the players attribute, and then on the client i want to read what that attribute ==. However, I get nothing returned?
-- Server
print("SET BLOCK ID")
player:SetAttribute("Block", BlockId)
print(player:GetAttribute("Block"))
-- Client
print(self.Player)
print(self.Player:GetAttribute("Block"))
Output
21:23:35.339 SET BLOCK ID - Server - InventoryManager:129
21:23:35.340 2 - Server - InventoryManager:131
21:23:35.374 NinjoOnline - Client - Block:36
21:23:35.374 - Client - Block:37
So, server is setting the Block attribute first, thus self.Player:GetAttribute(“Block”) on the client SHOULD return 2, but it doesn’t…
What is the self referring to? If you are wanting to get the client player you should do game.Players.LocalPlayer
NinjoOnline
(NinjoOnline)
September 12, 2021, 1:34pm
#3
I’m using inheritance, and so
function ItemHandler:new(player)
self.Player = player
end
and fire this function as so, so it is getting their local player
ItemHandler(Players.LocalPlayer)
Where did you place the print functions at? (Referring to where in the script not if it is on the client or server)
Could the client possibly be getting the attribute before its set? If not for that then I believe there’s a problem with the actual referencing.
NinjoOnline
(NinjoOnline)
September 12, 2021, 11:02pm
#6
Don’t see how it can. The server is clearly setting the attribute first, and when I do the getattribute print on the server right after its set it works, and the clients prints come after. And to my knowledge, attributes should have no delay and replicate immediately