Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

onTouch disable jumping?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

NOT A REQUEST! This is in a regular script in workspace. This disables jumping What I want is for a person not to be able to jump when they touch a vehicle part. How would I do that?

game.Players.PlayerAdded:connect(function(player) -- This is when player joins

    player.CharacterAdded:connect(function(character)

        local humanoid = character:findFirstChild("Humanoid")-- We are making a variable for the Humanoid

        if humanoid then -- If player then

            humanoid.Changed:connect(function(property)--We are messing with the player now

                if humanoid.Jump == true then-- When the player trys to jump

                    humanoid.Jump = false -- This wont let Him.

                    humanoid.Sit = false

                    humanoid.PlatformStand = false

                end

            end)

        end

    end)



    local character = player.Character



    if character then

        local humanoid = character:findFirstChild("Humanoid")

        if humanoid then

            humanoid.Changed:connect(function(property)

                if humanoid.Jump == true then

                    humanoid.Jump = false

                    humanoid.Sit = false

                   humanoid.PlatformStand = false

                end

            end)
        end
   end
end)

2 answers

Log in to vote
0
Answered by
iSvenDerp 233 Moderation Voter
8 years ago

Simple....I can not look over my script Because I have to go but Change humanoid.sit To true I believe. Not positive though.

humanoid.Sit = true

Let me know if it helped. Since I told you in server I'll tell u here. You asked me how to make a player sit and not get up in this script also so this might make it work. I am on mobile so I can't test it but it should make it to where humanoid is siting no matter what.

Ad
Log in to vote
0
Answered by 8 years ago

To prevent a player from jumping **AT ALL* on every respawn, we'll make the Jump property false everytime the Jump event is fired from their current Humanoid object.

game.Players.PlayerAdded:connect(  --Connects function to any player that joins the game
    function(plr)
        plr.CharacterAdded:connect( --Connects function to the Player's Character when it's added.
            function(char)
                local hum = char:WaitForChild('Humanoid')
                hum.Jumping:connect(
                    function()
                        hum.Jump = false
                    end
                )
            end
        )
    end
)

As for preventing a player from jumping while in a seat, use the same approach as the above to only connect it when the character is seated.

0
So this script disables jumping? FiredDusk 1466 — 8y
0
This does not work FiredDusk 1466 — 8y
0
It doesn't work because the character jumps before the Jumping event fires. You need to use RunService's RenderStepped event to make it work instead of the Jumping event, which you need to do in a LocalScript. Spongocardo 1991 — 8y

Answer this question