I want to make a script when someone sits on a seat a GUI will appear, how do I do that?
hi
plr = game.Players.LocalPlayer char = plr.Character or plr.CharacterAdded:Wait() if char.Humanoid.Sit == true then urGui.Enabled = true end
Hello there.
I will provide you with a script. In order to make it work, you need to put the script inside the seat, and the GUI inside the script.
If you have any further questions, feel free to comment or message me.
local seat = script.Parent local guiName = "TestGui" local gui = script:WaitForChild(guiName) local Players = game:GetService("Players") local lastplr -- each time the Occupant property of the seat fires... seat:GetPropertyChangedSignal("Occupant"):Connect(function() if seat.Occupant ~= nil then local char = seat.Occupant.Parent local player = Players:GetPlayerFromCharacter(char) local cloned = gui:Clone() -- cloned.TrainName.Value = script.Parent.Parent.Parent.Name cloned.Parent = player.PlayerGui lastplr = {player, cloned} -- store player and Gui in array else print("player left") if lastplr then -- verify lastplayer is not nil lastplr[2]:Destroy() -- since the table's numerically indexed, we know lastplr[2] will be the Gui lastplr = nil end end end)
-- Credit for code goes to XxELECTROFUSIONxX