Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is the player detecting itself?

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

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
0
do I need to add this is the current code? Puppy_lovertheawsome 84 — 2y
0
yea the basic idea is to check if the thing your hitting is hitting the thing you dont want to hit Puppynniko 1059 — 2y
Ad

Answer this question