How to make better trampolines?

My trampolines are just anchored block parts, to which I give a script

trampoline.Velocity = Vector3.new(0, bounce, 0)

They work, but in mysterious ways. Even tho the bounce value doesn’t change, they make the player jump different heights each time player touches them. I understand that this is because of how physics work, but I dont undertsand How to make them make player jump the same height each time?

1 Like

I found one solution

local trampoline = script.Parent
--trampoline.Velocity = Vector3.new(0, 200, 0)


trampoline.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.JumpPower = 300
		hit.Parent.Humanoid.Jump = true
		task.wait(0.2)
		hit.Parent.Humanoid.JumpPower = 50
	end
end)

but if you have better suggestion, please do suggest

1 Like

I recommend trying this:

local Force = 1e3
hit.Parent.HumanoidRootPart:ApplyImpulse(Vector3.new(0, Force, 0))

Also I found that your script doesnt have a debounce, here is a fix:
For the debounce to work properly make sure that the script is a local script, there will be no difference, except for maybe speed improvements.

local trampoline = script.Parent
local Force = 1e3 -- 1 followed by 3 zero's

local Debounce = false
trampoline.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) == game.Players.LocalPlayer then
		if Debounce then
			return
		end
		Debounce = true
		hit.Parent.HumanoidRootPart:ApplyImpulse(Vector3.new(0, Force, 0))
		task.wait(0.2) -- nice to see someone using task.wait() instead of the deprecated wait()
		Debounce = false
	end
end)

Try that and tell me if it works, if it does, mark my post as a solution!

1 Like

Change The Part>CustomPhysical>Density=0 and Elasticity=1
so there will be les bad bounce timing

local trampoline = script.Parent
trampoline.Velocity = Vector3.new(0, trampoline.Configuration.BounceSpeed.Value, 0)
trampoline.SurfaceGui.Enabled = false


and add this to the part

Adding a folder with that configuration is absolutely unnecessary. Also the surfacegui part without any actual surface gui hints that you pretty much copied a script from toolbox. Also you did the same thing I said I already tried. Thank you.

This will not work in a local script, because local scripts don’t work in workspace.

Just put the local-script into StarterPlayerScripts and reference the variables differently.

You could put it somewhere where it would run and change the variables or if that is not an option, something like this should work:

local trampoline = script.Parent
local Force = 1e3 -- 1 followed by 3 zero's

local Debounces = {}
trampoline.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if Debounces[hit.Parent] then
			return
		end
		Debounces[hit.Parent] = true
		hit.Parent.HumanoidRootPart:ApplyImpulse(Vector3.new(0, Force, 0))
		task.wait(0.2) -- nice to see someone using task.wait() instead of the deprecated wait()
		Debounces[hit.Parent] = false
	end
end)