I have tried looking into Google and the forum, but the script isn’t working. I have tried many, including the one below. I’m trying to force a player to jump when they click the close button on a GUI. The GUI is closing, but the player isn’t jumping. I would also like to add a cooldown for them before seating in any seat again.
Thank you so much for fixing it. I was wondering how do I enable the GUI to appear ONLY when the player sits on a chair and make it so that they can’t jump while seated?
The humanoid has a Sitting property you can listen to, and to disable jumping, you can simply set the JumpPower property to 0.
Example script:
game.Players.LocalPlayer.Character.Humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
if game.Players.LocalPlayer.Character.Humanoid.Sit == true then
script.Parent.Parent.Visible = true
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0
end
end)
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50
game.Players.LocalPlayer.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)
Hope this helps,
Fizzitix
(Edit: I’ve significantly improved the script above, please copy/paste it again)
(Edit 2: I noticed errors in the code and fixed them, please copy/paste it again)
local player = game.Player.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local holder = script.Parent.Parent
humanoid:GetPropertyChangedSignal("Sit"):Connect(function()
if humanoid.Sit then
holder.Visible = true
humanoid.JumpPower = 0
end
end)
script.Parent.MouseButton1Click:Connect(function()
holder.Visible = false
humanoid.JumpPower = 50
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)