.I have been trying to make a teleport gui but there is a error
This is the script:
local part = script.Parent local player = game.Players.LocalPlayer local TP = game.Workspace:WaitForChild("HouseTeleportIn") part.Touched:connect(function() wait(0.5) if player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").Visible == false then wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").Visible = true wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 1 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.9 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.8 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.7 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.6 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.5 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.4 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.3 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.2 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.1 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0 wait(0.1) player.Character:MoveTo(TP.Position) wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").Visible = true wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.1 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.2 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.3 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.4 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.5 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.6 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.7 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.8 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 0.9 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").BackGroundTransparency = 1 wait(0.1) player.PlayerGui.BlackScreenGui:WaitForChild("BlackScreen").Visible = false end end)
The error in the output says Workspace.HouseDoor.OuterPart.Script:7: attempt to index upvalue 'player' (a nil value)
Please fix the entire script and tell me what I did wrong.
This is likely a server script; there is no LocalPlayer on the server so player is nil. You need to code in the mindset that there is no known player. Or you can convert this to a LocalScript, but the script must be a descendant of a character or player. Then you need to learn about loops.
local screen = player.PlayerGui:WaitForChild("BlackScreenGui"):WaitForChild("BlackScreen") part.Touched:connect(function() if not screen.Visible then screen.Visible = true --increments variable "i" from 1 to 0 by -0.1 --screen uses this variable for i=1,0,-0.1 do wait(0.1) screen.BackgroundTransparency = i end player.Character:MoveTo(TP.Position) for i=0,1,0.1 do wait(0.1) screen.BackgroundTransparency = i end screen.Visible = false end end)