this is my first time ever scripting and im making a story game on roblox. im making the lobby and everything is fine until the gui to exit the bus didnt pop up, i checked the output and it says "attempt to index nil with clone" heres a part of my script
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) for i,v in pairs(Seats) do if Seats.Occupant == nil then hit.Parent.Humanoid.JumpPower = 0 hit.Parent.Humanoid.WalkSpeed = 0 Gui:Clone().Parent = player.PlayerGui <----- (where the problem occurs) player.Character.HumanoidRootPart.CFrame = Seats[math.random(1,17)].CFrame wait(10) player.PlayerGui.ExitGui:Destroy()
You would need to define GUI. I would recommend putting the GUI in ServerStorage and then defining this variable at the top of your code:
local GUI = game.ServerStorage.NAMEOFYOURGUI
You never set "Gui" as a variable so it is nil. Make sure you define it.
local original = game.ServerStorage.ExitGui -- change accordingly to where your Gui is and the name of it local Gui= original:Clone() Gui.Parent = player.PlayerGui