-
What do you want to achieve? I want to have a zero grav area that detects the player’s avatar with Region3
-
What is the issue? If will only detect my avatar when im in a certain part of it. And yes i checked that the region is made correctly
the regions size 129.855011, 85.7499847, 80.3750305
the regions position -487.279297, -95.1858597, -504.435791 -
What solutions have you tried so far? When starting work on the area i copied and modified a script from a different topic and i changed up the wait time for the loop but nothing worked
This is my script
local ZeroGravRegion = Region3.new(workspace.ZeroGravHelp.Part1.Position, workspace.ZeroGravHelp.Part2.Position)
print(ZeroGravRegion.CFrame)
print(ZeroGravRegion.Size)
workspace.ZeroGravHelp.Part3.CFrame = ZeroGravRegion.CFrame
workspace.ZeroGravHelp.Part3.Size = ZeroGravRegion.Size
local AntiGrav = 1
local gravforce = 196.2 * AntiGrav
print(gravforce)
while true do
for i, part in pairs(workspace:FindPartsInRegion3(ZeroGravRegion)) do
if part.Anchored == false then
local h = part.Parent:FindFirstChild("Humanoid")
print(part.Name .. " enter zero grav area") -- it should print the name one if not all of the parts in my avatar
if h then
if part.Parent.HumanoidRootPart:FindFirstChild("BodyForce") == nil then
local bforce = Instance.new("BodyForce")
bforce.force = Vector3.new(0, ((part.Parent.HumanoidRootPart:getMass())*gravforce)* 5.115, 0)
bforce.Parent = part.Parent.HumanoidRootPart
h.WalkSpeed = 0
end
else
local h2 = part.Parent.Parent:FindFirstChild("Humanoid")
if h2 then
if part.Parent.Parent.HumanoidRootPart:FindFirstChild("BodyForce") == nil then
local bforce = Instance.new("BodyForce")
bforce.force = Vector3.new(0, ((part.Parent.Parent.HumanoidRootPart:getMass())*gravforce)* 5.115, 0)
bforce.Parent = part.Parent.Parent.HumanoidRootPart
h2.WalkSpeed = 0
end
else
if part:FindFirstChild("BodyForce") == nil then
local bforce = Instance.new("BodyForce")
bforce.force = Vector3.new(0, ((part:getMass())*gravforce)* 5.115, 0)
bforce.Parent = part
end
end
end
end
end
wait() -- This is how long it waits between loops
end