#How could I manage multiple players' statuses without relying on client scripts?
10 messages · Page 1 of 1 (latest)
you can do this in multiple ways! the simplest would probably be just a boolean value under the player's character that gets changed.
so, lets say you insert a boolean value object under the player's character. you can do this anytime the player's character loads like this:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local newValue = Instance.new("BoolValue")
newValue.Parent = character
newValue.Value = false -- can be edited to true or false depending on what the current value is when the character loads, up to you!
end)
end)
then, you just change that value whenever something happens, like in this case, when the player draws their weapon
and you can call that value and check the value (if it's true or false) whenever needed
-- player = the player with the value being changed;
-- newValue = the new value (true or false in this case) that it's changed to
function ChangeBoolean(player, newValue)
local boolVal = player.Character and player.Character:FindFirstChild("BoolValue")
if boolVal then
boolVal.Value = newValue
end
end
the function above changes the boolean under the player's character to whatever value is provided
-- player = the player that the value is being grabbed from
function GetBoolean(player)
local boolVal = player.Character and player.Character:FindFirstChild("BoolValue")
return boolVal and boolVal.Value
end
the above returns the value you're trying to get (true or false depending on what it is in this case)
hope that all makes sense, lmk if you have questions :)