So, i made a telerpotation function where the function detect if each player is inside of the hitbox
The problem is that the detectation isn,t working
Even with the player inside of the hitbox, he teleports the player anyways
function TeleportPlayersInTheElevator()
local Plrs = TagSvc:GetTagged("Players In Game")
local Square = Elevator:WaitForChild("HitBox", 3)
for i, P in pairs(Plrs) do
if P then
local Character = P.Character
if Character then
local FindAsPartInPart = table.find(workspace:GetPartsInPart(Character.PrimaryPart), Square)
if not FindAsPartInPart then
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
if Humanoid.Sit ~= false then
local SeatPart = Humanoid.SeatPart
if SeatPart then
local SeatWeld = SeatPart:FindFirstChild("SeatWeld")
if SeatWeld then
SeatWeld:Destroy()
wait()
end
end
end
end
end
Character:PivotTo(Elevator.TeleportBox.CFrame)
end
end
end
end
I tried to search in the forum about this problem, and i found nothing.
I also tried to put a wait() after the hitbox creates (because previously the hitbox is created in the script),
and i tried to seek for the part name instead of the part itself
(i also printed all the parts touching the humanoid (inside of the hitbox) and suprisingly i found the hitbox in the table)