Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is the player detecting itself?

I am super confused why this is happening. I am making a game where you can randomly freeze
and another player has to touch you for you to be free. My issue is that when you freeze your body detects itself and then unfreezes you. Any ideas on how to fix this?

local player = game.Players.LocalPlayer
local character = player.Character
detected = {}
if character ~= nil then
	for _, part in pairs(character.HumanoidRootPart:GetTouchingParts()) do
		if game.Players:GetPlayerFromCharacter(part.Parent) ~= nil then
			if detected[game.Players:GetPlayerFromCharacter(part.Parent)] ~= nil then
                              detected.insert((game.Players:GetPlayerFromCharacter(part.Parent) == true #detected)
			end
			print("oof bugged again")
		end
	end
end

Sorry it looks rly messy I can't fit it in the box thing so it automatically goes to the next line ????

1 answer

✓ Accepted answer

Something like

local player = game.Players.LocalPlayer
local character = player.Character
local function Touched(Part)
	if Part.Parent ~= Character then
		print("Not Player")
	end
end

2 comments

0

do I need to add this is the current code?

0

yea the basic idea is to check if the thing your hitting is hitting the thing you dont want to hit

This discussion is preserved as it was. New answers, comments, and votes are closed.