Duplicate thread

Still having the same problem, with the script.

Any errors? If so please provide them!

Only error:

I have no idea what it means, so I can’t do anything.

Can you show me line 3 in your script?

That means local player = game.Players:GetPlayerFromCharacter(Hit.Parent) is nil.

The third line is:

local GUI = player.PlayerGui:FindFirstChild("ElevatorGUI")

Set the Screen GUI’s ResetOnSpawn property to false.

Okay, I will try that. Thanks for all the help!

Hmm, it didn’t work. Still not sure why this happening.

Found another error
10%20PM

local PlayersService = game:GetService("Players")
local Part = script.Parent
local ElevatorGui = script.Parent:WaitForChild("ElevatorGui")

local function OnTouch(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local Player = PlayersService:GetPlayerFromCharacter(Hit)
        if not Player:WaitForChild("PlayerGui"):FindFirstChild("ElevatorGui") then
            ElevatorGui:Clone().Parent = Player.PlayerGui
            ElevatorGui.Frame.Visible = true
        else
            ElevatorGui.Frame.Visible = false
        end
    end
end

Part.Touched:Connect(OnTouch)

Polished the code. Let me know if there are any errors. Also, feel free to change the variables however you would like to. Insert this script into the invisible part and insert the GUI into the invisible part as well.

I’ll try it, let you know if it works!

Still not working. Not sure why…

May you provide the error in the output (if there is one). Also, this should be ran through a server script which should be inside of the invisible part as well.

Do you want me to the put the invisble part into ServerScriptService/

No, keep it in workspace. Put the script (server script) inside the invisible part. Make sure to put the GUI inside the invisible part as well.

They are both inside the invisible part.

Instead of what @Mystic_StarShowers did, try this;

local PlayersService = game:GetService("Players")
local Part = script.Parent
local ElevatorGui = script.Parent:WaitForChild("ElevatorGui")

local function OnTouch(Hit)
    if Hit.Parent:FindFirstChild("Humanoid") then
        local Player = PlayersService:GetPlayerFromCharacter(Hit.Parent) --hit shouldn't be there, it should be hit.Parent
        if not Player:WaitForChild("PlayerGui"):FindFirstChild("ElevatorGui") then
            ElevatorGui:Clone().Parent = Player.PlayerGui
            ElevatorGui.Frame.Visible = true
        else
            ElevatorGui.Frame.Visible = false
        end
    end
end

Part.Touched:Connect(OnTouch) 
1 Like

I forgot the hit.Parent aspect lol. Thanks for fixing up the code.

1 Like