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

"attempt to index nil with 'PlayerGui' " How do i fix this ?

Asked by
Komas19 34
3 years ago

Im trying to make an story game. (The script is an Normal Script)

local function challenge_1()
    local guide_Image = "rbxassetid://7359283182"
    local plr = game:GetService("Players").LocalPlayer
    local gui = plr.PlayerGui.DarkScreen.Frame.LocalScript
    local work = game:GetService("Workspace")
    local boat = work.Boat
    local tp = work.BoatTeleport

    boat.Bottom.Smoke.Enabled = true
    getRandomPlayer()
    CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"What is all this smoke ?")
    wait(2)
    boat.Bottom.Fire.Enabled = true
    CreateDialogueEvent:FireAllClients(guide_Image,"FIRE !!!")
    wait(2)
    gui.Disabled = false
    tp.Tp.Script.Disabled = false
    wait(10)
    gui.Disabled = true
    boat:Destroy()
    tp:Destroy()
end

1 answer

Log in to vote
2
Answered by 3 years ago

The reason is because you are trying to access the localplayer in a server sided script. You can only access localplayer in a local script.

0
thx Komas19 34 — 3y
Ad

Answer this question