Hi!
I am the least experienced scripter in the history of scripters, and I am in need of help.
The thing I need is a brick which forces the player to sit, but prohibits them to jump.
This brick is to put at the start of a slide. I want the player to sit all the way through the slide down, so they can't simply jump and walk down.
A script I pulled out of the free models library (I'm sorry guys, if I could script myself, I would do it) already takes care of the sitting part:
01 | enabled = true |
02 | function onTouched(hit) |
03 | if not enabled then return end |
04 | enabled = false |
05 | local h = hit.Parent:findFirstChild( "Humanoid" ) |
06 | if (h ~ = nil ) then |
07 | h.Sit = true |
08 | end |
09 | enabled = true |
10 | end |
11 | script.Parent.Touched:connect(onTouched) |
It is possible that only a single line of code is enough to make this work, but unfortunately I have yet to be successful.
The player should be allowed to jump again when the bottom is reached (or if they die).
I hope someone can help me! Thanks in advance.
Maybe try turning off the animation
01 | --Turn off anim |
02 | enabled = true |
03 |
04 | function onTouched(hit) |
05 |
06 | if not enabled then return end |
07 | enabled = true |
08 | local h = hit.Parent:findFirstChild( "Humanoid" ) |
09 | if (h ~ = nil ) then |
10 | h.JumpPower = 0 -- DEFAULT IS 50 |
11 | h.Sit = true |
12 | h.Animation.Disabled = true |
13 | --[[ wait(5) TAKE OFF (--[[ and ]] if you want to return to normal after a certain amount of time. |
14 | h.Animation.Disabled = false |
15 | h.JumpPower = 50 |
16 | ] ] |
17 | end |
18 | end |
Maybe try this:
01 | local shouldSit = true |
02 |
03 | function onTouch(obj) |
04 | local human = obj.Parent:FindFirstChild( "Humanoid" ) --Find humanoid |
05 |
06 | if human then --If there is a player touching |
07 | while shouldSit do --If they should sit |
08 | human.Sit = true --Keep them sitting |
09 | wait() --Make sure the program doesn't crash |
10 | end |
11 | end |
12 | end |
13 |
14 | script.Parent.Touched:Connect(onTouch) |
If this didn't work, let me know and I'll debug it.