For some reason this script isnt executing

title says it all, this is a local script in workspace

local guardtext = "B"
local theiftext = "A"
local Infogui = game.StarterGui.InfoGui.Info
local localplayer = game.Players.LocalPlayer
local alreadydisplayed = true

while task.wait(0.1) do
    print("Debug Loop")
    if alreadydisplayed == true and localplayer.Team == game.Teams.Spectator then
        alreadydisplayed = false
    end
    
    if alreadydisplayed == false then --Display Team Info
        alreadydisplayed = true
        if localplayer.Team == game.Teams.Theif then
            Infogui.Visible = true
            Infogui.Text = theiftext
            task.delay(7, function()
                Infogui.Visible = false
            end)
        elseif game.Players.LocalPlayer.Team == game.Teams.Guards then
            Infogui.Visible = true
            script.Parent.Text = guardtext
            task.delay(7, function()
                Infogui.Visible = false
            end)
        end 
    end
end

i dont think its a code issue, because i put a breakpoint before the main loop and it didnt get triggered
the script is enabled, and its not a location issue

local scripts never run in the workspace, it has to be a server script.

edit: judging by this code, this could easily go into StarterPlayerScripts

is it not printing “Debug Loop”?

yeah local scripts dont run in workspace it has to be in the starterplayerscripts or startercharacter or starterpack or startergui

Bruh, thanks. i cant believe i never knew this

1 Like

of course, take a look at valid containers for localscripts

if im not able to use localscripts in the workspace, then why arent they grayed-out on the insert tool?

I don’t know, but I’m guessing it used to work in an earlier update and they forgot to grey it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.