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

Why is FindPartsInRegion3 code only working in robox studio but not online?

Asked by 7 years ago

when i run the script in studio it works fine but when i run online it dont do anything

function GetPlayersAroundBrick(brick)
local n = 0
for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") then
    if v:FindFirstChild("Humanoid") ~= nil then
local start_point = start1.Position
local end_point = end1.Position
local Region = Region3.new(
    Vector3.new(
        math.min(start_point.X, end_point.X),
        math.min(start_point.Y, end_point.Y),
        math.min(start_point.Z, end_point.Z)
    ),
    Vector3.new(
        math.max(start_point.X, end_point.X),
        math.max(start_point.Y, end_point.Y),
        math.max(start_point.Z, end_point.Z)
    )
)
for _, part in pairs(workspace:FindPartsInRegion3(Region, beam, math.huge)) do
    if part.Parent:FindFirstChild("UpperTorso") ~= nil and part.Parent.Name ~= Character.Name then  
n = n + 1
damage = Player.Data.Level.Value
        humanoid = part.Parent:FindFirstChild("Humanoid")

        torso = part.Parent:FindFirstChild("LowerTorso")

        humanoid.Health = humanoid.Health - damage

        torso.CFrame=torso.CFrame+root.CFrame.lookVector

    end
end     
    end
    end
return n
end
end

Answer this question