How would I make these kind of 2D platforms?

Currently in my 2D platformer I want to make it so if there’s a platform above you, you’re able to go through it. But once you’re on top of the platform, it’s collideable again. Here’s what I’m talking about:


I’ve tried doing this myself but it keeps breaking somehow:

And the code for it:

script.Parent.Touched:Connect(function(hit)
	if (hit.Parent:FindFirstChild("Humanoid") ~= nil) then
		script.Parent.Parent.CanCollide = true
	elseif (hit.Parent:FindFirstChild("Humanoid") == nil) then
		script.Parent.Parent.CanCollide = false
	end
end)

You could implement a wait() delay, then make the Part’s colission set to true? (Although I’d recommend setting a debounce)

You can simply check if the player is below the platform or not.

if player.Position.y < platform.Position.y then
    platform.CanCollide = false
else
    platform.CanCollide = true
end
1 Like