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

How would i make a brick so when you step on it it will make you jump without the space button?

Why won't this work?

function onTouch()
game.Workspace.Player.CFrame
game.Workspace.Player.CFrame.new (-6,79,26)--the cframe is an example of the cframe

game.Player.onTouch()
end

1 answer

✓ Accepted answer

Without debounce:

script.Parent.Touched:connect(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		p = game.Players:GetPlayerFromCharacter(hit.Parent)
		p.Character.Humanoid.Jump = true
	end
end)

With debounce:

function debounce(func)
    local isRunning = false
    return function(...)
        if not isRunning then
            isRunning = true
            func(...)
            isRunning = false
        end
    end
end


script.Parent.Touched:connect(debounce(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		p = game.Players:GetPlayerFromCharacter(hit.Parent)
		p.Character.Humanoid.Jump = true
	end
end))

1 comment

0

Thanks!This works!

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