I have been trying to create an AFK command. Once AFK is said, it fires a remote that initiates the other script to add a forcefield to the character and change an overhead rank and name displayer to say AFK. Once they say it again, the forcefield is destroyed and their rank resets to what it said previously. The event works in Studio and Online Mode, but other players can not see the changes made to the player (i.e. Forcefield, AFK name). I'm pretty sure I used the wrong remote. (Ignore the "done" remote below.)
Firing Script (Located in Workspace):
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("afk") game.Players.PlayerAdded:connect(function(player) if player:GetRankInGroup(3445873) >= 2 then player.Chatted:connect(function(msg) if string.sub(msg, 0,4) == "!AFK" then print("Noticed AFK said") remote:FireClient(player) print("Fired") end end) end end)
Local Script Receiving Event (Located in StarterGUI): (Has two children: BoolValue called AFK and a StringValue called Original)
local afkRank = 2 local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("afk") local uAFK = script:WaitForChild("AFK") local doneRemote = repStorage:WaitForChild("done") remote.OnClientEvent:connect(function() if uAFK.Value == false then print("Not AFK") Instance.new("ForceField",game.Workspace:FindFirstChild(script.Parent.Parent.Name)) local playerModel = game.Workspace:FindFirstChild(script.Parent.Parent.Name) local rankGUI = playerModel:FindFirstChild("Rank") print("Found the rank thing!") local original = rankGUI.Frame.TextLabel.Text rankGUI.Frame.TextLabel.Text = "AFK" print(original) script.Original.Value = original uAFK.Value = true elseif uAFK.Value == true then print("AFK") local playerModel = game.Workspace:FindFirstChild(script.Parent.Parent.Name) local rankGUI = playerModel:FindFirstChild("Rank") print("Found the rank thing for turning back!") rankGUI.Frame.TextLabel.Text = script.Original.Value playerModel.ForceField:Destroy() uAFK.Value = false end end)
Do I need to use a different remote? Please help! Thank you.