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

How do I make GUI only show for a player that is seated and not everyone else?

Can anyone assist me if they can? I made a GUI eject button for when i enter the bus i teleport and sit on a seat, once i'm seated i then made it so that an eject button GUI pops up and i can eject, but if one person goes and sits in the bus and makes the GUI appear, it also appear for everyone else in the server and they can use it as well, I would like to know how to make it so that the GUI only appears for the player that gets seated. Also, Once i click the eject button the player teleports with the seat attach and is seated, i tried to make the player jump when it teleport but i dont know how to execute it. By the way, this is all in a local script in StarterGUI

**local db = true local player = game.Players.LocalPlayer local target = game.Workspace.EjectPlace --THIS IS SEAT 1 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat2.ChildAdded:connect(function() player = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat1.Occupant.Parent) script.Parent.Visible = true end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false
player2.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end) --THIS IS SEAT 2 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat2.ChildAdded:connect(function() player2 = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat2.Occupant.Parent) script.Parent.Visible = true end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false
player2.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end) --THIS IS SEAT 3 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat3.ChildAdded:connect(function() player3 = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat3.Occupant.Parent)

script.Parent.Visible = true

end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false

player3.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end) --THIS IS SEAT 4 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat4.ChildAdded:connect(function() player4 = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat4.Occupant.Parent)

script.Parent.Visible = true

end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false

player4.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end) --THIS IS SEAT 5 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat5.ChildAdded:connect(function() player5 = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat5.Occupant.Parent)

script.Parent.Visible = true

end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false player5.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end) --THIS IS SEAT 6 workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat6.ChildAdded:connect(function() player6 = game.Players:GetPlayerFromCharacter(workspace.Bus1.Truck.VS3.Body.Seats.SeatsFolder.Seat6.Occupant.Parent)

script.Parent.Visible = true

end) script.Parent.MouseButton1Click:Connect(function() if db == true then db = false

player6.Character.HumanoidRootPart.CFrame = target.CFrame * CFrame.new(-16, 3.5, 90.505) game.Players.LocalPlayer.Character.Humanoid.Jumping = true script.Parent.Visible = false

db = true end end)**

1 comment

0

lol, this was in the discord xd

2 answers

So, GUI is always client sided unless you have some sort of server based gui.

If you wanted to trigger the gui you could do

hasSat = false
seat.Touched:Connect(function() 
    if seat.Occupant == nil and not hasSat then
	    hasSat = true   
	    screenGUI.Enabled = true
    end 
end)
seat.TouchEnded:Connect(function()
   if hasSat and seat.Occupant ~= nil then
	   hasSat = false
	   screenGUI.Enabled = false
   end
end)

This would be in a local script. (This is just a concept not the exact solution)

You can use this basic script to do it, since its local, you don't have to get the players sitting on a certain seat but instead it will detect if the Local Player is sitting on that certain seat.

local seat = workspace.Chair.Seat -- Change to your seat
local player = game.Players.LocalPlayer
local gui = player.PlayerGui:WaitForChild("ScreenGui").EjectButton

gui.MouseButton1Click:Connect(function()
player.Character.Humanoid.Sit = false
end)

while wait() do -- Change to whatever function you want
if seat.Occupant == player.Character.Humanoid then
	gui.Visible = true
else
	if seat.Occupant == nil then
gui.Visible = false
end
end
end -- end for while loop!

Hope it helps you!

5 comments

0

I did this and i made 6 local seats (1 through 6) because there are different seats, But the ejection GUI doesnt pop up once im in the seat

0

Also it says Humanoid is not a valid member of Model

0

The GUI won't show up because of the identifier which is in line #1 'local seat = workspace.Chair.Seat' thus it Identifies only 1 Seat, So You would wanna use :GetChildren() (https://developer.roblox.com/api-reference/function/Instance/GetChildren) or if not then Create 6 seats and name them individually it can be (Seat1, Seat2, Seat3, etc...) and for each local scripts must have their own seat id

0

for short, you create 6 localscripts and change the seat to the name of the seat.

0

Alright i put them into 6 local scrips and it pops up now, but it also pops up for everyone else and they can click it, and when they do click it it teleports the player on their screen, but on the actual person that sitting down, on their screen they are still in the bus. Do i need to put the local scripts into each seat? i have them all in the screen GUI

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