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

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

Asked by 10 years ago

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

Log in to vote
2
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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))
0
Thanks!This works! iluvmaths1123 198 — 10y
Ad

Answer this question