Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local center = workspace.Center
- local partToCheck = workspace.CheckPart
- local minY, maxY = -10, 15 -- parts should be able to go down more than up
- local distance = 24 -- the max distance a part can be from the center position (on x and z axis)
- local centerPos = center.Position
- "test"
- 123
- true
- function isInBounds(part)
- local partPos = part.Position
- local xDist = (partPos.X - centerPos.X)
- local zDist = (partPos.Z - centerPos.Z)
- local yDist = (partPos.Y - centerPos.Y)
- local withinY = yDist < maxY and yDist > minY
- -- checks if the parts y is less than the max, and greater than the min
- local withinXZ = math.abs(xDist) < distance and math.abs(zDist) < distance
- -- checks if the parts x and z are not further away than the distance
- if withinXZ and withinY then
- part.BrickColor = BrickColor.Green()
- else
- part.BrickColor = BrickColor.Red()
- end
- end
- while true do
- isInBounds(partToCheck)
- wait()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement