Recreation of the Repulsion gel from Portal 2

Hello, im making a garry’s mod game on Roblox, with source engine games stuff, and ive been stuck on trying to recreate it

the issue is: i cannot negate the fall damage from the repulsion gel, and i want it to bounce you back up the same height as you fell

i did try looking at the forum but there was only 2 posts that did not help me

all i got is this

local part = script.Parent
local multiplier = 1.5 -- Adjust this to control bounce intensity
local debounceTime = 0.2
local debounce = {}

local function onTouched(otherPart)
    local character = otherPart.Parent
    local humanoid = character and character:FindFirstChildOfClass("Humanoid")
    local rootPart = character and character:FindFirstChild("HumanoidRootPart")
    
    if humanoid and rootPart and not debounce[character] then
        debounce[character] = true
        local incomingVelocity = rootPart.Velocity.Y
        local bounceForce = math.abs(incomingVelocity) * multiplier
        rootPart.AssemblyLinearVelocity = Vector3.new(rootPart.AssemblyLinearVelocity.X, bounceForce, rootPart.AssemblyLinearVelocity.Z)
        
        task.delay(debounceTime, function()
            debounce[character] = nil
        end)
    end
end

part.Touched:Connect(onTouched)
1 Like

the issue looks like this
robloxapp-20250305-1139041.wmv (2.0 MB)

Is the script actually running to start with? Have you checked with if-statements?

Also, you do not need to do character and character:… because we already know character is definitely an object.

wait let me attempt that, ill update you

i came up with some debugging and delete the character and character thing but it still doesnt work

local part = script.Parent
local multiplier = 1.5 -- Adjust this to control bounce intensity
local debounceTime = 0.2
local debounce = {}

print("Running")

local function onTouched(otherPart)
	local character = otherPart:GetRootPart().Parent
	local rootPart = character:FindFirstChild("HumanoidRootPart")

	if rootPart and not debounce[character] then
		print("checked")
		debounce[character] = true
		local incomingVelocity = rootPart.Velocity.Y
		local bounceForce = math.abs(incomingVelocity) * multiplier
		rootPart.AssemblyLinearVelocity = Vector3.new(rootPart.AssemblyLinearVelocity.X, bounceForce, rootPart.AssemblyLinearVelocity.Z)
		print("Bounced")

		task.delay(debounceTime, function()
			debounce[character] = nil
		end)
	end
end

part.Touched:Connect(onTouched)

everything is printing correctly and when it needs to, its just, not bouncing

Ooohhhh, i think i found it, it might be because the union has can collide on,

CanCollide? More like CanTouch off would be the issue. Check the collision box too.

1 Like

collision fidelity is set to default, im gonna test it with box, then with precise if it doesnt work

it kind of works, but only when i hold jump, and the force isnt fast enough, it lags a bit, enough to make me take fall damage
robloxapp-20250307-1856471.wmv (5.0 MB)

precise made my studio not respond lol

hull might be the best one but still, i need to hold jump for the gel to work

You are always going to suffer lag and unreliability with Touch events. The best way to tackle it would be to use a raycast to detect the gel.

that is such a great idea, thank you im going to test that!!

thank you so much, it worked man!!!