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

problem with a local that indicate a local player gui , how to fix it?

Asked by
322ita 15
3 years ago
Edited 3 years ago

i have a problem with a local here is the script

local plr = game.Players.LocalPlayer
local casa = workspace.casaAvere
local sound = script.wrong
local gui = plr.PlayerGui.hous
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if not casa.Value == true then
        if player.leaderstats.bobux.Value>50 then
            local name = script.Parent.teSTO.name
            player.leaderstats.bobux.Value = player.leaderstats.bobux.Value-50
            local textlabel = script.Parent.teSTO.SurfaceGui.TextLabel
            name.Value = player.Name
            textlabel.Text = name.Value .."'s house"
            casa.Value = true
        end
    end
    if casa.Value == true then
        gui.Enabled = true
        sound:Play()
        wait(2)
        gui.Enabled = false

    end


end)

here is the error Workspace.test.Script:4: attempt to index nil with 'PlayerGui'

0
LocalPlayer is for LocalScript, not Script. 9mze 193 — 3y

1 answer

Log in to vote
0
Answered by
322ita 15
3 years ago
Edited 3 years ago

i fixed the script


local casa = workspace.casaAvere script.Parent.ClickDetector.MouseClick:Connect(function(player) local gui = player.PlayerGui.hous if not casa.Value == true then if player.leaderstats.bobux.Value>50 then local name = script.Parent.teSTO.name player.leaderstats.bobux.Value = player.leaderstats.bobux.Value-50 local textlabel = script.Parent.teSTO.SurfaceGui.TextLabel name.Value = player.Name textlabel.Text = name.Value .."'s house" wait(2) casa.Value = true end end end)

.

local casa = workspace.casaAvere
local sound = script.wrong

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local gui = player.PlayerGui.hous
    if casa.Value == true then
        gui.Enabled = true
        sound:Play()
        wait(2)
        gui.Enabled = false

    end
end)

i divided the scriptt in 2 so the gui wont appear for the first time

Ad

Answer this question