Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this Pop Up GUI working?

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!

2 comments

1

Why are you disabling the script on line 5?

0

It's only supposed to run once, and only once.

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.