So what I understand about replicatedstorage is thats its accessible from both the server and the client, which makes it the ideal parent of lets say a remoteevent. The server is able to see that [player name] invoked [remoteevent name] lets do [action] and visa versa.
But i cannot find a way to access a clients replicated storage from the server, heres my script:
local function getAllPlayersAreReady()
local allPlayersAreReady = true
for _, player in ipairs(game.Players:GetPlayers()) do
if game.ReplicatedStorage.opted.Value == true then
print("lol")
end
end
end
My first thought was the server should invoke the client and the client would send back the value, but it say here that that is not advised. I thought of using remote events, following the lines of the server is gonna invoke the client, then the clien invokes the server back with the details, but that seems like a lot of work, and maybe the client might leave during that, in which the server is gonna hang, not good for the players and the games stats.
In hindsight using
game.ReplicatedStorage.opted.Value == true
is not a good idea, but thats why I am here. no output errors, also, would there be any other place for a bool value to be stored that would be accessible from the client and more importantly the server?
Any ideas?
Why not use attributes? You would still need a remote event but OnServerEvent you would set the attribute to true, which indicates that the player voted. That way you can check if player:GetAttribute("Opted") then.
Ok, but for some reason that is not working, heres my script if you wanna take a look:
while wait(1) do
for _, player in ipairs(game.Players:GetPlayers()) do
if player:GetAttribute("Opted") == true then
if player.Character then player.Character:BreakJoints()
end
end
end
end
I changed it from a print to a death just in case te output was showing client side only.
What environment are you setting the attribute from? This code is only going to work if the server sets the attribute. Attributes are like properties in that they don’t replicate if set by a client. If you’re testing with the command bar then you need to switch to the server environment before setting it.