Help with collision

I’m trying to do a doodle jump system, where you can go through the bottom part of the mesh/part and stand on top of the mesh/part. It works here.
robloxapp-20230330-1815207.wmv (1.2 MB)
And it doesnt work here:
robloxapp-20230329-0048058.wmv (1.1 MB)

Thats the whole script:

local bossFightsNumber = {6,15,28,46,70,101,149,207,276,360,469,653}

local function createPlatform()
	local starterPlatform = workspace.Naruto.StartPlatform:Clone()
	starterPlatform.Parent = workspace.Platforms
	starterPlatform.CFrame = workspace.Platforms.FirstPart.CFrame
	
	local count = 1
	local maxCount = 653
	while true do
		print(table.find(bossFightsNumber, count) == nil)
		if table.find(bossFightsNumber, count) == nil then
			local newPart = Instance.new("Part")
			newPart.Anchored = true
			newPart.Transparency = 1
			newPart.Parent = workspace.Platforms.ReferenceParts
			newPart.Name = count

			local oldPartName = count - 1
			local oldPart = workspace.Platforms.ReferenceParts:FindFirstChild(oldPartName)
			if oldPart then
				local oldX = oldPart.CFrame.Position.X
				local distance = oldX - workspace.Platforms.FirstPart.CFrame.Position.X
				local X

				if distance > 0 then
					X = math.random(-distance, distance)
				else
					X = math.random(distance, -distance)
				end
				if distance < 10 or distance > -10 then
					X = math.random(-60,60)
				end
				local Y = oldPart.CFrame.Position.Y
				newPart.CFrame = CFrame.new(workspace.Platforms.FirstPart.CFrame.Position + Vector3.new(X,Y+40,0))
			else
				local X = math.random(-60,60)
				newPart.CFrame = CFrame.new(workspace.Platforms.FirstPart.CFrame.Position + Vector3.new(X,30,0))
			end

			local NarutoPlatform = workspace.Naruto.Platform:Clone()
			NarutoPlatform.Parent = workspace.Platforms
			NarutoPlatform.CFrame = newPart.CFrame
		else
			local newPart = Instance.new("Part")
			newPart.Anchored = true
			newPart.Transparency = 1
			newPart.Parent = workspace.Platforms.ReferenceParts
			newPart.Name = count
			
			local oldPartName = count - 1
			local oldPart = workspace.Platforms.ReferenceParts:FindFirstChild(oldPartName)
			local Y = oldPart.CFrame.Position.Y
			newPart.CFrame = CFrame.new(workspace.Platforms.FirstPart.CFrame.Position + Vector3.new(0,Y+40,0))
			
			local NarutoPlatform = workspace.Naruto.BossPlatform:Clone()
			NarutoPlatform.Parent = workspace.Platforms
			NarutoPlatform.CFrame = newPart.CFrame
		end
		
		
		
		if count ~= maxCount then
			count += 1
		else
			break
		end
		wait()
	end
end

local function clearPlatform()
	for i, part in pairs(workspace.Platforms:GetChildren()) do
		if part:IsA("MeshPart") and part.Name ~= "FirstPart" then
			part:Destroy()
		end
	end
	for i, part in pairs(workspace.Platforms.ReferenceParts:GetChildren()) do
		part:Destroy()
	end
end

createPlatform()
1 Like

To do that, create a LocalScript in StarterCharacterScripts and then on RunService.RenderStepped event check if the character’s HumanoidRootPart CFrame is 1.5 studs higher than the platform’s top and if it is then set the platform CanCollide property to true

Here’s the code to check if character’s HumanoidRootPart CFrame is higher than the platform’s top by a threshold value

local platformHeight = 1 -- Change this to your platform's height
local threshold = 1.5 -- How much higher above the platform the HumanoidRootPart must be in order for the platform to be collidable

if platform.CFrame:ToObjectSpace(humanoidRootPart.CFrame).Y > platformHeight / 2 + threshold then
	platform.CanCollide = true
else
	platform.CanCollide = false
end
1 Like