Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Which type of remote do you use with this type of script? Would you use a RemoteFunction instead?

Asked by 6 years ago

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.

0
This should all be handled on the server. When you create a force field in the character on the client, it's local, meaning it will only be seen by the local player. The same goes for the rank tag Gey4Jesus69 2705 — 6y
0
So should it be a RemoteFunction that fires the server? Would I have to move my scripts or change any of the code? iFizzics 3 — 6y
0
don't need to use any remote functions Leamir 3138 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Hello wowie! I am here to answer you. You have been placing the right event. You should use a RemoteEvent in that situation. :)

0
I'm already using a RemoteEvent. Could you elaborate, because this didn't help. iFizzics 3 — 6y
Ad

Answer this question