Trying to make scp 018

What do you want to achieve? Ball that bounces 200% but with a speed limit

What is the issue? ball gets so much speed it clips out of the world (in a closed room)

What solutions have you tried so far? I tried making a while true loop that checks if speed is higher than an amount but it didnt work

Im kinda bad at scripting but here

local ball = script.Parent
local cap = false
ball.Touched:Connect(function(object)
	if not cap then
		if object:IsA("Part") then
			ball:ApplyImpulse(ball.AssemblyLinearVelocity * 0.4)
		end
	end
end)


while true do
	local power = ball.AssemblyLinearVelocity.Magnitude
	task.wait(.3)
	if power >= 40 then
		cap = true
	else
		cap = false
	end
end

You can use math.clamp() to limit values, in this case:

power_check = math.clamp(power, 0, 40)
1 Like

sorry if i dont know stuff but i never worked with most of math library so how would i put it in the code

You can integrate it by using it as a capacitor, math.clamp() uses the following arguments:

math.clamp(Value, Min_Value, Max_Value). If the value is below minimum, default to minimum. If it’s above maximum, default to maximum. If not, it’ll just use the number you provided.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.