Trying to disable the ability for a player to jump out of a seat. I tried setting jump power to 0.
4 Likes
coolifysz
(coo1ify ok)
November 21, 2023, 2:42am
#2
Try using Humanoid.Jumped
and in the function use :Sit() to make them sit on the seat again.
1 Like
Set JumpHeight to 0. This can be located in the Humanoid.
1 Like
Doesn’t work. When I press spacebar my character falls out of the seat.
1 Like
It worked when I tried it, I’m not sure why it’s not working for you.
Alternatively, you can either weld/anchor them or unbind the action temporarily.
You may use ContextActionService to temporarily unbind the Jump event.
local ContextActionService = game:GetService('ContextActionService')
ContextActionService:UnbindAction("jumpAction")
Alternatively you can use this approach with UserInputService.
-- Services
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
-- Local player
local player = players.LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:Wai…
cuberoot5
(lohak)
November 21, 2023, 3:23am
#6
Check out these posts:
Note: The debounce and crash only happen when this is done from the client. If done from the server, it should work as expected.
The crash will definitely be fixed, as will the debounce on Sit. As for your approach on preventing players from exiting seats, a property would probably not be the best way to control this. Adding bool toggles for optional behavior creates API bloat over time. In this case, you should just kill the jump keybind clientside while the player is sitting:
game:GetService…
I want to make it so the player cannot leave a seat for my game, But I don’t know how to do it.
They involve methods other than Jump Power (for the 2nd see the reply on SetStateEnabled). Are they of any help?
1 Like
Doomcolp
(dxxmed)
November 21, 2023, 3:29am
#7
Maybe you could just anchor the player’s HumanoidRootPart after they sit
1 Like
got this from another post maybe this will help:
local Seat = script.Parent -- Path to seat
Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if Seat.Occupant ~= nil then
local Char = Seat.Occupant.Parent
Char["HumanoidRootPart"].Anchored = true
-- Can also set their jump power if wanting, your preference
end
end)
(mods dont take this down)
3 Likes
Doomcolp
(dxxmed)
November 21, 2023, 3:29am
#9
That’s legit what I was just about to say lol
Great minds think alike
I found the issue, another script was causing the issue.
2 Likes
system
(system)
Closed
December 5, 2023, 3:48am
#11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.