.Touched Events Prematurely killing players

I am currently making an obby-themed minigame-based game, and one of the minigames is a Wipeout-themed spinner. If the spinner is touched by a player, it is meant to kill the player.

However, as seen below, you can see that often, the spinner prematurely kills the player.

I have a .Touched event attached to each player’s humanoid, that detects when the spinner is touched, and it then kills the player, as seen in this code:

hum.Touched:Connect(function(touchingPart: BasePart, humanoidPart: BasePart) 
		if touchingPart.Name == "kill" then
			hum.Health = 0
		end
	end)

How can I improve this?

Try using a local script to detect when player touches part

1 Like

Yeah Roblox has a serious issue with server refresh rate. I hope they bring an option to change it though, but that would bring new issues. The problem with doing it on a local script is it makes it very hackable.

What you could do is make it so when the server touches it, it sends an event seeing if the client side finds it as good.

1 Like

Tried this, and the issue still happens. Honestly, it was a bit worse. It’s actually quite bizarre.

Weird. Did the local script not work or my idea didn’t?

I was relying to @iATtaCk_Noobsi, so his local script did not work. I tried yours, and it did not work either.

The same thing(s) happened, where the premature touch occurred

You can’t use a normal local script. you have to use a server script under the part, then change the run context to client and put the touched code there

1 Like

If the spinner uses a server script to change its orientation then just delete that and replace it with a hinge constraint motor. Works much better for me.

@wastbo This ran slightly better, but it would still kill players if they cleared well of the spinner.

@keremMCT, this already uses HingeConstraints.

This was the result of your suggestion. Instead of issues horizontally, it seems like it has issues detecting hits vertically.

Change the collision fidelity to precise on the mesh

What other games do, is they have the spinner created on the client, and the touched code running in a local script. However, not all clients will see the spinner at the same location at the same time.

1 Like

maybe try considering putting the kill script on the spinny thing?

spin.Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild(“Humanoid”) then
hit.Parent.Humanoid.Health = 0
end
end)

or just use some more advanced hitbox modules, ex: raycast hitbox v4 or muchuchao hitbox

That was given before I came to the DevForums for help

What you are suggesting here was suggested by @wastbo prior, and it offered marginal improvements, but did not solve the issue completely.

The solution was found when I ended up making a script where:

  1. The spinner is on the server. All clients see the spinner at the same time, unless there is some horrific lag. The spinner’s CanTouch property is set to false.

  2. I had an event fire for all clients, where the spinner’s CanTouch property is set to true, on the client.

  3. In the same code in #2, I had a .Touched event created, and it fired a remote. Firing that remote kills the player that fired it.

This isn’t perfect, and it will possibly allow for exploiting, but it really fixed the issue here that I spent the better part of 1-2 hours trying to resolve. Resulted in accurate .Touched detection

1 Like

Did you revert it back to the default when* it didn’t work?

No, but changing its CollissionFidelity had no effect on the issue. It seems to be a very big ROBLOX replication issue that @RocketSlither mentioned earlier, unless you have stuff run on the client like @SelDraken suggested

It was running on the client so I’m not sure how it didn’t work, but it’s good you found a fix

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