Environment¶
Service Object
This object is automatically created by Polytoria. Additionally, scripts cannot change its parent.
Not newable
This object cannot be created by scripts using Instance.New()
Environment is the primary object intended for storing active objects in the place.
Inherits Instance
Methods¶
CreateExplosion → void
¶
Parameters
Position [ Vector3 ]
Radius [ number
= 10
]
Force [ number
= 5000
]
affectAnchored [ boolean
= true
]
callback [ function
= nil
]
Creates a deadly explosion killing players and applying force to parts at the given position.
Example
game["Environment"]:CreateExplosion(Vector3.New(0, 0, 0), 30, 5000, false)
When set to true, AffectAnchored will unanchor parts within the explosion radius.
Callback gets called for each part within explosion radius.
Raycast → RayResult¶
Parameters
origin [ Vector3 ]
direction [ Vector3 ]
maxDistance [ number
= infinite
]
ignoreList [ array
= Instance[]
]
Casts a ray from origin with a specified direction and returns a RayResult for the first hit object.
Example
local hit = game["Environment"]:Raycast(barrel.Position, barrel.Forward)
if hit and hit.Instance:IsA("Player") then
hit.Instance.Health = 0
end
RaycastAll → RayResult¶
Parameters
origin [ Vector3 ]
direction [ Vector3 ]
maxDistance [ number
= infinite
]
ignoreList [ array
= Instance[]
]
Casts a ray from origin with a specified direction and returns a RayResult array for all hit objects.
Example
local hits = game["Environment"]:RaycastAll(Vector3.New(0, 10, 0), Vector3.New(0, -1, 0), 100)
for i, hit in pairs(hits) do
print("Hit at " .. hit.Position .. "!")
end
Properties¶
FogColor : Color¶
The color of the fog. Fog is a visual effect that makes the world look like it is covered in a colored mist.
Example
Change the fog color to white:
game["Environment"].FogColor = Color.New(1, 1, 1, 1)
FogEnabled : boolean
¶
Whether or not fog is enabled.
FogStartDistance : number
¶
The distance from the camera at which fog starts to appear
FogEndDistance : number
¶
The distance from the camera at which fog is fully opaque
Gravity :
Vector3 = Vector3.New(0, -75, 0)
¶
The direction and strength of gravity in the world
PartDestroyHeight : number
¶
The height at which unanchored parts are destroyed when they fall below it.
Example
game["Environment"].PartDestroyHeight = -2000
Skybox : SkyboxPreset¶
The default skybox preset to use for the world, if no ImageSky is present.