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

Why isn't this Pop Up GUI working?

Asked by 9 years ago

I asked in an earlier question why my script was not working, and what I had thought WAS working apparently was NOT working.

This is the code that I believed was working, I had edited it from TheAlphaStigma, who replied to the previous question.

local jumpp = game.Workspace:WaitForChild("jumpp");
local dooropen = game.Workspace:WaitForChild("Dooropen");

script.Parent.Touched:connect(function(hit)
    script.Disabled = true
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        for i,v in pairs(jumpp:GetChildren()) do
        v.Transparency = 0
    end
    wait(.2)
    game.Lighting.scare:Clone().Parent = player.PlayerGui
    dooropen.Windowinv.Transparency = 0
    dooropen.Window.Transparency = 1
    dooropen.Windowframeinv.Transparency = 0
    dooropen.Windowframe.Transparency = 1
    dooropen.DoorBottominv.Transparency = 0
    dooropen.DoorBottom.Transparency = 1
    dooropen.Window.CanCollide = false
    dooropen.Windowinv.CanCollide = true
    dooropen.Windowframe.CanCollide = false
    dooropen.Windowframeinv.CanCollide = true
    dooropen.DoorBottom.CanCollide = false
    dooropen.DoorBottominv.CanCollide = true
end)

As soon as the brick is touched, the output displays "Workspace.dejump.Script:11: attempt to index local 'player' (a nil value)"

The brick is supposed to clone a ScreenGui in Lighting to the player's GUI.

Any suggestions would be most appreciated. Thanks!

1
Why are you disabling the script on line 5? Mystdar 352 — 9y
0
It's only supposed to run once, and only once. sidekick83 80 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

When a part that doesn't belong to a player hits it, then it will try and find a player from a normal part. You can either us an if then statement or pcall

local jumpp = game.Workspace:WaitForChild("jumpp");
local dooropen = game.Workspace:WaitForChild("Dooropen");

script.Parent.Touched:connect(function(hit)
    script.Disabled = true
if  game.Players:GetPlayerFromCharacter(hit.Parent) then
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
end
        for i,v in pairs(jumpp:GetChildren()) do
        v.Transparency = 0
    end
    wait(.2)
    game.Lighting.scare:Clone().Parent = player.PlayerGui
    dooropen.Windowinv.Transparency = 0
    dooropen.Window.Transparency = 1
    dooropen.Windowframeinv.Transparency = 0
    dooropen.Windowframe.Transparency = 1
    dooropen.DoorBottominv.Transparency = 0
    dooropen.DoorBottom.Transparency = 1
    dooropen.Window.CanCollide = false
    dooropen.Windowinv.CanCollide = true
    dooropen.Windowframe.CanCollide = false
    dooropen.Windowframeinv.CanCollide = true
    dooropen.DoorBottom.CanCollide = false
    dooropen.DoorBottominv.CanCollide = true
end)

Ad

Answer this question