Touched event doesn't work when jumping

I am making a spleef-type game, with platforms that disappear from underneath you after a bit of time. The problem is, the onTouch() does not seem to work when a player jumps, so if a player continually jumps on the platform, it does not disappear.

I have seen many other posts on this problem, but they are for kill blocks, so the solution for those is to turn can collide off. I cannot do that because players need to stand on these platforms for about 1 second before they disappear. I have tried making an invisible layer of platforms above the real ones, but for that to work I would need to do something where in each invisible platform’s script it tells the corresponding real platform to turn transparent and disappear. I have about 400 platforms so I really don’t want to do that.
This is my existing code:


local isTouched = false

local fadeReturnPart = game.Workspace.FadeReturn

local function fade()
	if not isTouched then
		isTouched = true
		for count = 1, 10 do
			platform.Transparency = count / 10
			wait(0.1)
		end
		platform.CanCollide = false
		
		fadeReturn = fadeReturnPart:GetAttribute("fadeReturn")
		
		while fadeReturn == false do
			wait(0.01)
			fadeReturn = fadeReturnPart:GetAttribute("fadeReturn")
		end
		platform.CanCollide = true
		platform.Transparency = 0
		isTouched = false
	end
end

platform.Touched:Connect(fade)

Notes:

  • fadeReturnPart is a part that I change the attribute on in a server script to reset all the platforms
  • This code was made a bit ago when I didn’t know about repeat ___ until ___, and I based it off of the Roblox tutorial for making a disappearing platform
1 Like

Like the original solution to this was to turn can collide off to make the touched events register. I would suggest duplicate your spleef tiles and move them a little bit higher than the original tiles. You can make the duplicated tiles invisible and turn can collide off on those and let the touch events get executed on those invisible bricks and make the baseparts under the invisible one disappear.

You could use Region3, but that would be messy.

That is what I tried earlier, but I really dont want to have to recode 400 parts to do it. Is there some way for my parts with the code to know what part is under it? Do you think using a touched event or similar and then applying the transparency and can collide to whichever part is touching it would work?

1 Like

You can use a ray to shoot downward a part and to grab the part the ray managed to hit and store it in a variable for the script, that is parented under the invisible part and the invivnle part on top of the visible part. Basically make a repeat until loop with the ray until it has found the part it is on top of and then modify that part when the invible part on top of it gets touched by a human or player. I’m on mobile, when I get home I could try writing the code if this sounds confusing.

I think it makes sense, I dont really know how to do the rays though. It may be worth it to just delete them all, remake the script, and parent each visible one under each invisible one. I was imagining something where I would have "part1, part2, part3… invisPart1, invisPart2, invisPart3… and the I would need to edit the name and code in each one, so making one the child of the other one would be a lot more doable. I will still need to copy and reposition each one, then each row, then each layer etc, but it is a lot less work then recoding 400 parts.

Would the ray script be a one time thing, just to parent each one and then be done with it, or would it run every time?

1 Like

Witht he ray you would put the script in the invis part and the script will determine which part it is on top of so it could be more efficient as it would be a one time thing to script and just paste the script under each invis part that is on top of a part that is going to be “spleefed” lol. Hope that makes sense, but your method could still consume time for sure! Like you said it could be more doable for you. The efficient ways are always the ones I usually go for.

Btw, could I see an image of the arena or map or link me to the game to see?

Is the game R15? I have made a spleef type game before with R6 only and it works just fine, but when I try to have it as R15, it breaks and stuff doesn’t disappear.
Try making the game R6 to see if that is the problem.

Have you managed to get the R15 spleef to work like the R6?


I dont have studio open right now, so this is just my picture for the game thumbnail, because I have it saved on my computer. There aren’t actually lines between the squares, I just selected all of them when I took my picture so it was more clear.

Here is the game link: Platform Fade (Spleef) - Roblox

I tried changing it to r6, but now my in place teleport doesn’t work, giving me the error message that LeftLeg is not a valid member of Model “Workspace.FinnBotF11” I am using the teleport module on develporer.roblox.com. When it was supposed to teleport me, it just froze me in place, so I could jump but not move.

Ok so I joined to game to test the soleef plataforms and the game wouldn’t start lol I just stood still. Guessing you set my walkspeed to 0. This actually looks like a pretty good map that the raycasting would work like a charm. Of course that’s a lot of parts. You could just create ONE part and code that part and when the map is being loaded, that the script clones those part and builds the map instead of you manually placing them side by side. That’s more efficient

Yea, I had that same problem too, it worked fine until I changed the character model. I will look through the script, I am guessing it is something like it is trying to find all of the parts in the character and move them, but r6 doesn’t have the same part names.

Ok, I could probably do the cloning then, it is probably less work than me trying to get the raycasting to work.

I also changed it back to r15 but haven’t re-tested it, so the teleport should work but I haven’t tried.
EDIT: The teleport works again when I put it back to r15

1 Like

The game is actually very similar to mine, but my game having 200 visits and hasn’t been updated in a few months, you probably game up with the idea. What I did for my game was make a single script that recognizes parts that had an int value with a certain name, and then give them a function inside the master script so there would only need to be one script and every map can fully functional tiles. This could work for you, but another way to do it if you don’t want to do the other method, is the make custom animations. I figured out this bug a while ago, that R15 avatars don’t get detected but while jumping, but it is not that simple. R15 jumping and falling animations are the reason why it’s buggy, for example: the default jumping and falling animations cause this bug, so you could try changing the animation to having the feet be kind of still in the air, or just change it to whatever works for you.

Sorry about our games being similar, I can confirm I did not copy your game (my sister suggested the idea originally)

Hmm I could try with the animations, but I have no idea how to do that, so there would be a lot of learning to do.

Like I said just work on the script on one invisible part while putting under the visible block. And then when the game starts, just clone it and give each part a certain distance from each other in rows in columns to make the map. This would be done woth nested for loops

Is this something I could do once, and then save somehow? Or do I need to build it every time?

Also the name is stupidly close, I don’t really care that, TileDrop, and Platform Fade are super close lol. Anyways, I could do some animations for you, whenever I have sometime. I’ll test it out for you also whenever.

I’m gonna try scripting the cloning and parented parts first, and see if that will work, but thank you.

1 Like

Yes do it once and technically you woukd just need to edit the rows and columns variables to determine how big u want the map

My solution to this would be to create a hitbox part on the player’s feet like so. Place this script in ServerScriptService! After doing that, you can keep the original script you had for the tiles. Hope this was helpful!

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
	local torso = char:WaitForChild("HumanoidRootPart")
	local newPart = Instance.new("Part", char)
	newPart.Massless = true
	newPart.CanCollide = false
	newPart.Anchored = false
	newPart.Name = 'Hitbox'
	newPart.Transparency = 1

	local weld = Instance.new("Motor6D", torso)
	weld.C0 = CFrame.new(0, -2.5, 0)
	weld.C1 = CFrame.new()
	weld.Part0 = torso
	weld.Part1 = newPart
end)

end)