I have been working on an AFK button, but I have hit a roadblock. The screen GUI I have changes the leaderboard, but since its a local script it does not replicate when the server script checks. How do I fix this? here are my scripts: Example of Server script:
for i, player in ipairs(game.Teams.Spectators:GetPlayers()) do
if player.leaderstats.AFK.Value == false then
print(player.leaderstats.AFK.Value)
--do stuff
end
end
Local script:
function Click()
if AFK == true then
AFK = false
elseif AFK == false then
AFK = true
end
if AFK == true and player.Team ~= Teams.Smashers then
script.Parent.Text = "AFK"
player.leaderstats.AFK.Value = true
print(player.leaderstats.AFK.Value)
elseif AFK == false and player.Team ~= Teams.Smashers then
script.Parent.Text = "PLAYING"
player.leaderstats.AFK.Value = false
print(player.leaderstats.AFK.Value)
end
end
script.Parent.MouseButton1Down:Connect(Click)

5 comments
remote event
Instead of writing "if bool == true" you could do "if bool". Same with "if bool == false" -> "if not bool"
RemoteEvent:FireServer()
RemoteEvent:FireServer(player) would fire the event to the server using the player argument. Use that.
@MCAndRobloxUnited No, you'd be sending the player as an extra argument like that. It would look like: OnServerEvent(player, player).