Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

onTouch disable jumping?

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

✓ Accepted answer

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.

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.

3 comments

0

So this script disables jumping?

0

This does not work

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.