#hello, i made safezone, and when going from 1 to other(theyre connected but not colliding) it breaks

1 messages · Page 1 of 1 (latest)

gusty vector
#
    if not hit.Parent:FindFirstChild("Humanoid") then return end
    if hit.Parent:FindFirstChild("ForceField") then return end
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    Instance.new("ForceField", hit.Parent)
    local backpack = player:WaitForChild("Backpack")
    local children = backpack:GetChildren()
    for _, child in ipairs(children) do
        child.Parent = player:WaitForChild("ItemsFolder")
    end
end
script.Parent.Touched:Connect(whentouchedOn)

function whentouchedOff(hit)
    if not hit.Parent:FindFirstChild("Humanoid") then return end
    if hit.Parent:FindFirstChild("ForceField") then
        hit.Parent.ForceField:Destroy()
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local backpack = player:WaitForChild("ItemsFolder")
        local children = backpack:GetChildren()
        for _, child in ipairs(children) do
            child.Parent = player:WaitForChild("Backpack")
        end
    end
end
script.Parent.TouchEnded:Connect(whentouchedOff)```
long blade
#

Ah ive had this issue too, the best way to fix it is to make a general table with bodyparts and checking if colliding parts are already in the table

gusty vector
#

how?

#

script in serverscriptservice?

#

and how to make general table

#

@long blade

open zealot
#

use collection service btw

gusty vector
#

whats that

long blade
long blade
gusty vector
#

у

#

local tableparts = {workspace.SafeZone, workspace.SafeZone1}

#

@long blade

long blade
#

No alr wait i cant make a big example bc phone but

#

local table = {}

#

Part.touched:function()

#

If hit.parent/FindFirstChild("humanoid")

#

Table.insert(table, hit)

#

Table is not same as table

#

And to checj

#

For i, v in table do

#

If hit == table then

#

-- safe = true

#

Else

#

Can do the same for leaving

gusty vector
#

ty man