How do you make a Gui show when you sit on a chair?

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve? : when you sit in a chair in my game a ui pops up with a button you click it and you start to make income and when you click the button again the money stops coming in

  2. What is the issue? :I am very new to scripting and I have no clue where to start

  3. **What solutions have you tried so far?**I looked in plenty of YouTube videos and read topics but could find somewhere to start

I am not asking you guys to write a whole script for me or anything I just need help on where to look in order to start scripting for this, sorry I am very new

4 Likes

Well you could add the GUI and then put a script so that if you are sitting in a chair the GUI pops up, and when you click the button it starts a while true do that adds a certain amount every second or every few seconds and it breaks if you click it again.

You could probably make the gui appear by doing:

if humanoid.Sit == true then but that would probably spark some problems.

for the gui, use a mouseclick event. and add a debounce so it can’t be abused.

1 Like

Also to learn how to use those use the Developer Hub.

I would recommend using the Seated event. It fires when you either sit in or get up from a seat/vehicleseat.

See Humanoid.Seated for more information.

From there, all you’d need to do is make the interface visible for the specified player. You can read more on creating GUI buttons here.

1 Like
-- local script
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local gui = script:WaitForChild("gui")

humanoid.Seated:Connect(function(isSeated, seat)
    if (isSeated) then 
        gui.Visible = true 
    end
end)

This provides what you need. Please use the developer hub and attempt to solve this issue on your own. Problem solving is a great skill to learn and prepare you for life outside of this.

14 Likes

Thank you guys for helping I really appreciate all the help I can get I’ll take not of everything thank you all I’m just in the beginning of my journey of becoming a game developer

1 Like

Good luck and most importantly try and have fun lol

1 Like

If you want a specific seat to trigger your function, use Seat.Occupant. This is a property that returns the humanoid of the player sitting in the seat.

Good luck with your future projects!

4 Likes

You will want to use the if humanoid.Sit == true then system.

If you need more help, please do reply.

1 Like

Also you should use some remote events because, GUI’s can only be enabled with a local script so put a local script in the GUI so that the GUI pops up when the Remote Event is fired.

1 Like