#Issue With Bounce Pad Script

1 messages · Page 1 of 1 (latest)

ebon swallow
#
    if hit.Parent:FindFirstChild("Humanoid") then
        local humanoid = hit.Parent:FindFirstChild("Humanoid")
        
        humanoid.JumpHeight = 75
        humanoid.Jump = true
        
        animateBounce() -- Animates a bouncy mushroom to do a bounce animation
        
        wait(0.25)
        
        humanoid.JumpHeight = 7.2
    end
end

pad.Touched:Connect(jump)```

I need some help with this code. I'm trying to make a bounce pad, and it works for the most part. My only problem is that if the player tries to jump ONTO the bounce pad, the bounce pad waits until the player hits the ground before applying the "jump = true"
novel lintel
#

that's because of how .Touched operates

ebon swallow
novel lintel
#

there're a few, but I'm guessing they'd all be a little more expensive

#

you could use RunService with :GetTouchingParts()

ebon swallow
novel lintel
#

you could probably mathematically split up the surface area into points and raycast a unit or 2 up

vestal bluffBOT
#

studio** You are now Level 4! **studio

novel lintel
ebon swallow
#

im REALLY new to coding so im quite lost

novel lintel
#

a while loop probably

ebon swallow
vestal bluffBOT
#

studio** You are now Level 1! **studio

novel lintel
ebon swallow
#

ill try it

novel lintel
#

I attempted to experiment with it in studio a little bit, touched and :gettouchingparts are essentially the same thing, so that's my bad

#

the only issue with what I wrote is the latency

#

so I don't think my method was very effective

ebon swallow
#

it still has that annoying delay

sterile thicket
ebon swallow
#

it seems more instant only because I put an invisible part at the bottom of the red part of the mushroom so it hits a solid surface faster

#

ill send one video without it

ebon swallow
sterile thicket
#

what does the collision box of the mushroom look like

ebon swallow
sterile thicket
#

no im saying like

#

uh

#

nvm it wouldnt change shit

ebon swallow
#

the bounds of the collision check are exact

sterile thicket
ebon swallow
#

you touch red = you jump

sterile thicket
#

yeah uh

#

runservice

#

might be good for this

#

like the other guy said

#

do like

ebon swallow
#

can you give me a code example?

sterile thicket
#

local runService = game:getService("RunService")
runService.Heartbeat:connect(function()
--your jump shit here
end)

ebon swallow
#

the game lags

vestal bluffBOT
#

studio** You are now Level 2! **studio

sterile thicket
ebon swallow
#

this is true

sterile thicket
#

heres how to disconnect something

#

local runService = game:getService("RunService")
local runConnection
runConnection = runService.Heartbeat:connect(function()
if runConnection then
runConnection:Disconnect()
runConnection = nil
end
--your jump shit here
end)

#

i think something like that idk

rose patio
#

@ebon swallow just use .touched on the client

rose patio
#

Even if it’s “not safe”, that really doesn’t matter since exploiters can just run a script to fly or jump even higher

rose patio
# ebon swallow what

So in a client script, just loop through all the bounce pads, and use .touched on that invisible hitbox thing

#

This negates the latency since it’s on the client + it’s more accurate

sterile thicket
rose patio
#

.touched is also a lot more optimized than running a heartbeat for every single jump pad

#

Especially if you’re using that many heartbeats on the server

#

It’s bound to cause a memory leak

sterile thicket
#

or

#

or

#

if you wanted to be fucking different

#

use collection service

#

put all bounce pads in a folder

#

loop through the folder

#

apply just one script so all do the same thing

#

BAM

#

heartbeat and easy disconnect

rose patio
#

That’s what I JUST said

sterile thicket
#

yeah but liek

#

server

#

buddy\

rose patio
#

Latency…

sterile thicket
#

im going

#

to actually touch you

rose patio
#

ok

ebon swallow
rose patio
#

do you know what .touched is

#

no way

ebon swallow
rose patio
#

oh

#

thats not a good way of doing it

ebon swallow
#

I made it a child of the invisible part

rose patio
#

you should be using bodyvelocity

ebon swallow
rose patio
vestal bluffBOT
#

studio** You are now Level 5! **studio

ebon swallow
rose patio
#

one second

#

let me script it

ebon swallow
#

k

rose patio
#

@ebon swallow

#
local Debris = game:GetService("Debris")

local Player = game.Players.LocalPlayer
local Character = Player.Character

local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")


local jumpPadsFolder = workspace:WaitForChild("JumpPads")


local settings = {
    jumpForce = 80,
    velocityLifeTime = .5
}

local Connections = {}


local function jump(object)
    local bodyVelocity = Instance.new("BodyVelocity", HumanoidRootPart)
    bodyVelocity.MaxForce = Vector3.yAxis * HumanoidRootPart.AssemblyMass^2 * workspace.Gravity
    bodyVelocity.Velocity = Vector3.yAxis * (object:GetAttribute("JumpForce") or settings.jumpForce)

    Debris:AddItem(bodyVelocity, (object:GetAttribute("VelocityLifeTime") or settings.velocityLifeTime))
end

local function registerJumpPad(object)
    if object:FindFirstChild("Hitbox") then
        Connections[object] = object.Hitbox.Touched:Connect(function(h)
            if h:IsDescendantOf(Character) then
                jump(object)
            end
        end)
    end
end

local function removeJumpPad(object)
    if Connections[object] then
        Connections[object]:Disconnect()
        Connections[object] = nil
    end
end


for i, jumpPad in jumpPadsFolder:GetChildren() do
    registerJumpPad(jumpPad)
end

jumpPadsFolder.ChildAdded:Connect(registerJumpPad)
jumpPadsFolder.ChildRemoving:Connect(removeJumpPad)

#

localscript in startercharacterscripts

ebon swallow
#

it seems like I need something on top of that

rose patio
#

what

ebon swallow
#

what's a jumpPads folder?

rose patio
#

you need to make one

sterile thicket
#

workspace

#

and name it jumpPads

rose patio
#

JumpPads

#

capital j

#

unless you change it in the script

ebon swallow
#

yes

rose patio
#

also change the name of hitbox

#

in the script

#

if the invisible part isnt named Hitbox

#

bro i really want the scripter role

#

but im WAYYYY too lazy to apply

sterile thicket
#

and a touched event

#

and say

#

yup

#

s1

#

the standards for s2 isnt exactly clear btw

#

idk why they gatekeep that

rose patio
#

i dont even know the standards for anything

#

i dont even know what s1 or s2 is

#

or whatever this NONSENSE is

sterile thicket
#

you make a ticket

#

then apply for scripter

#

: D

rose patio
#

too lazy

sterile thicket
#

fair enough

#

its just a server rank so it doesnt matter much tbh

rose patio
#

yeah

sterile thicket
#

but its cool if youre ever curious about what other people think

#

some dont really give good feedback though

ebon swallow
rose patio
ebon swallow
#

well yes

#

but what is object

rose patio
ebon swallow
#

ohhh ok

sterile thicket
#

you gave him something he doesnt understand 💔

#

@ebon swallow id ask questions about how the script works so you know what youre using

rose patio
#

i shouldve explained it actually

rose patio
#

instead of spoonfeeding it

#

to him

ebon swallow
#

I think I got it working

rose patio
rose patio
#

its funny how that works out

ebon swallow
#

indeed I did

#

Did you maybe mean childremoved

sterile thicket
#

he probably did

rose patio
#

yeah

#

i typed it out without any

#

type definition

ebon swallow
#

seeeee I know what im talking aboout

rose patio
#

because i didnt wanna do :: Model

#

or :: Folder

#

in this case

ebon swallow
#

so its just not working

#

theres not even an error

sterile thicket
ebon swallow
#

yes

rose patio
ebon swallow
rose patio
#

💔 i wonder why it isnt working

#

no way it just deleted

ebon swallow
#

its only one part

rose patio
#

oh

ebon swallow
#

theres no model

#

should it be a model?

sterile thicket
rose patio
#
local Debris = game:GetService("Debris")

local Player = game.Players.LocalPlayer
local Character = Player.Character

local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")


local jumpPadsFolder = workspace:WaitForChild("JumpPads")


local settings = {
    jumpForce = 80,
    velocityLifeTime = .5
}

local Connections = {}


local function jump(object)
    local bodyVelocity = Instance.new("BodyVelocity", HumanoidRootPart)
    bodyVelocity.MaxForce = Vector3.yAxis * HumanoidRootPart.AssemblyMass^2 * workspace.Gravity
    bodyVelocity.Velocity = Vector3.yAxis * (object:GetAttribute("JumpForce") or settings.jumpForce)

    Debris:AddItem(bodyVelocity, (object:GetAttribute("VelocityLifeTime") or settings.velocityLifeTime))
end

local function registerJumpPad(object)
    if object.Name == "InvisPart" then
        Connections[object] = object.Touched:Connect(function(h)
            if h:IsDescendantOf(Character) then
                jump(object)
            end
        end)
    end
end

local function removeJumpPad(object)
    if Connections[object] then
        Connections[object]:Disconnect()
        Connections[object] = nil
    end
end


for i, jumpPad in jumpPadsFolder:GetChildren() do
    registerJumpPad(jumpPad)
end

jumpPadsFolder.ChildAdded:Connect(registerJumpPad)
jumpPadsFolder.ChildRemoving:Connect(removeJumpPad)

sterile thicket
#

sanchez locked in

rose patio
sterile thicket
rose patio
#

thats bare minimum buddy

sterile thicket
#

i mean yea

ebon swallow
#

so... its smooth, but I still hit the ground

sterile thicket
#

but to me its just a jump pad

ebon swallow
#

can we give it a little more oomph somehow

rose patio
sterile thicket
rose patio
#

or if thats not enough

#

i made it so that

#

you can add attributes

#

to the jumppad

sterile thicket
ebon swallow
#

what does velocitylifetime change

rose patio
#

how long youre flying

#

in the air

rose patio
ebon swallow
#

so indirectly just the height

#

ok

rose patio
#

i mean

#

if you really want

ebon swallow
#

so more force less lifetime?

vestal bluffBOT
#

studio** You are now Level 3! **studio

rose patio
#

i can make it just adjusting the height

#

instead

#

and calculate the velocity

#

from that

sterile thicket
#

let him figure it out 😭

rose patio
#

idk how to explain things bro 💔

#

its just simple math to calculate it anyway

sterile thicket
#

you can make the ideas so just explain it in those small pieces

rose patio
#

s=d/t

sterile thicket
#

mhm

ebon swallow
#

I know some of these words

rose patio
#

sanches

#

whoops

#

sanchez

#

bro

#

change the velocity based on s/dt

#

fuck

#

s=d/t*

#

my bad

sterile thicket
#

muah

#

@rose patio do you know any other game engines 💔

rose patio
#

absolutely not

ebon swallow
#

real

rose patio
#

ive wasted half my lifespan on roblox

sterile thicket
#

fuck

ebon swallow
#

roblox is cheeks

rose patio
#

i know python though

sterile thicket
#

ive been wanting to use godot

rose patio
#

and html js and whatnot

sterile thicket
#

ah

#

W

rose patio
#

all the basic shit

#

python is really really similar to lua

sterile thicket
sterile thicket
#

cant complain though

#

roblox does a lot of the heavylifting and hand holding for you

ebon swallow
#

@rose patio is there a way I can make a velocity barrier before the ground that prevents the player from going too far down

rose patio
#

what

ebon swallow
# rose patio what

like, the closer the player gets to the floor, the more velocity is applied to the player or something

#

so if the player is just before the floor, they get infinity velocity applied or something so they dont hit the ground

#

I just really dont want the player hitting the floor

ebon swallow
rose patio
#

nope

ebon swallow
sterile thicket
#

maybe like

ebon swallow
#

@rose patio is it possible

sterile thicket
#

if y velocity is at a certain point

#

make the other time higher

#

to compenstate for how fast theplayer is going

#

actually scrap that

#

dont listen to that

ebon swallow
#

is there a way to cancel velocity

sterile thicket
ebon swallow
#

thatd work

#

just cancel before applying the new velocity

sterile thicket
#

yea

rose patio
#

im so confused

sterile thicket
#

wait no

#

dude idk

#

😭

ebon swallow
#

that way its impossible to hit the ground

sterile thicket
ebon swallow
#

its just so they stop falling before they get pushed up

#

I dont want them to hit the ground

#

that has to make sense

rose patio
#

oh

sterile thicket
#

heh yeah bub i got a solution

rose patio
#

add to the jump function
HumanoidRootPart.AssemblyLinearVelocity = Vector3.zero

sterile thicket
#

nevermind its the most dumbest shit

rose patio
#

oh shoot

#

i forgot

#

to add

#

a debounce

#

whatevr

ebon swallow
#

OH MY GOD IT WORKS

#

WOOOO

rose patio
#

ill stop now 🙏

ebon swallow
#

okay well it doesnt FULLY work

ebon swallow
#

we forgot about the animation

rose patio
#

bro...

#

that has nothing to do with the bodyvelocity

ebon swallow
#

oh wait

#

I can just re-enable the other script

#

let me try it

rose patio
#

what was the point of me writing allat then 💔

ebon swallow
rose patio
#

or

#

you can just

#

transfer the animation part

#

into the client

#

becasue thats better

ebon swallow
#

but why wouldnt I want the bounces to be visible to everyone

rose patio
#

animations are one of the only things that roblox lets the client show the server

#

like

#

the default roblox animate script

#

is all client sided

#

as an example

ebon swallow
ebon swallow
sterile thicket
ebon swallow
#

@rose patio @sterile thicket good news the animation and jumping work perfectly

rose patio
#

w

ebon swallow
#

I also added a boioioioing sound effect

vestal bluffBOT
#

studio** You are now Level 4! **studio

ebon swallow
#

thanks guys

#

good teamwork 🫡