Help With Local script Touched() updating to all local script players

hey so i have smth that when touched adds more time to the players bomb timer, its a local script but for some reason it seems to update every single players bomb time even if only one guy touched it?

extratimeblock1.Touched:Connect(function(hit)
    if debounce == false then
        debounce = true
        bombtime += 15
    end
end)
``` i dont even see how this is possible since its on a local script,, any ideas?

Touched events fire for everyone and anything that triggers the touch. Its not local. If you want it specific to one player then you need to do checks to who touched the part

1 Like

how would i check who touched the part?

Something like this:

Part.Touched:Connect(function(hit) 
	local PlayerWhoTouched = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if not PlayerWhoTouched then return end
	
	print(PlayerWhoTouched)
        --Do stuff with this player
end)

In this case, you would check if PlayerWhoTouched is the same as the local player and then add the bomb time

It would be more correct to use hit:FindFirstAncestorOfClass(“Model”), in case of part’s parent being another part and not model.

It doesn’t matter because when a player touches a part, one of their main body parts that is under the character will also touch the part. Also, this would just make it so that accessories are detected also not just the body parts so it depends on what you want to check for

uh… its still doing it, i added this part

	local PlayerWhoTouched = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if not PlayerWhoTouched then return end
``` and its still changing it for everyone,, what now?

if PlayerWhoTouched ~= game.Players.LocalPlayer then return end although I wouldn’t recommend doing whatever you are trying to do as localscript changes will no be seen by the server without remote events.

1 Like

THANK U THANK U!! IT WORKS!! its all apart of a bomb timer while loop, when the bombtime hits 0 it fires a remote event that explodes the player with a buncha effects

1 Like