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

How to create an AFK Button Gui to change character folder?

Asked by 4 years ago

Expanding upon my last question, I need a system to switch the player's character between two workspace folders: Spectating and AFK. I've tried delays and other things and the script still doesnt work, with output returning "attempt to index nil value" errors. I'd also like to know whether I should use a regular script or a LocalScript.

local afk = workspace.AFK
local spectating = workspace.Spectating
local button = script.Parent
local player = game.Players.LocalPlayer

button.MouseButton1Click:Connect(function()
    wait(1)
    if player.Character.Parent == spectating then
        button.Text = "COME BACK"
        player.Character.Parent = afk
    end
    if player.Character.Parent == afk then
        button.Text = "GO AFK"
        player.Character.Parent = spectating
    end
end)
0
Rather than inserting a player's character to a folder, why not have a boolean value inserted to the character that's named "AFK" so you can toggle it. Also you're trying to accomplish this through a local script, this won't work for the player being inserted in the "afK" folder since it'll only be local (it'll only change for you). Try using remote events for that part. Player1_Joined 271 — 4y

Answer this question