Hello. My name is suberon Please help me to end my project "EVEREST" I need snow at my server Thank you.
COMMUNITY QUESTION
How to add to my game snow?
1 answer
local Players = game:GetService("Players")
local Configuration = {
SnowModelName = "ThatSnowRenderModel";
SnowColor = Vector3.new(1, 1, 1);
SmallestFlakeSize = 8;
LargestFlakeSize = 15;
MaxMoveX = 5;
MinMoveX = -5;
MaxMoveY = 1;
MinMoveY = -12;
MaxMoveZ = 5;
MinMoveZ = -5;
CyclesPerLifeMax = 4;
CyclesPerLifeMin = 2;
CycleLife = 20;
MaxTransparency = 0.3;
RangeX = 8;
RangeY = 4;
RangeZ = 8;
SnowAmountFactor = 3;
}
local function GetSnowModel()
local Model = workspace:FindFirstChild(Configuration.SnowModelName)
if not Model then
Model = Instance.new("Camera", workspace)
Model.Name = Configuration.SnowModelName
Model.Archivable = false;
end
return Model
end
local function GetSnowflakeMovement()
return Vector3.new(
math.random(Configuration.MinMoveX, Configuration.MaxMoveX)/100,
math.random(Configuration.MinMoveY, Configuration.MaxMoveY)/100,
math.random(Configuration.MinMoveZ, Configuration.MaxMoveZ)/100
)
end
local function GetRandomSnowflakePosition(LastValidPlace)
return CFrame.new() + LastValidPlace:pointToWorldSpace(Vector3.new(
math.random(-Configuration.RangeX, Configuration.RangeX),
math.random(-3, Configuration.RangeY),
math.random(-Configuration.RangeZ*2, 0)))
end
local SnowflakeQueue = {}
local function UpdateQueue()
local HalfLife = Configuration.CycleLife;
local MaxTransparency = Configuration.MaxTransparency
local Index = 1
while Index <= #SnowflakeQueue do
local SnowFlake = SnowflakeQueue[Index]
local CycleTick = SnowFlake.CycleTick
local Flake = SnowFlake.Flake
if SnowFlake.Mode == 2 then
SnowFlake.CyclesLeft = SnowFlake.CyclesLeft - 1
if SnowFlake.CyclesLeft <= 0 then
SnowFlake.Flake:Destroy()
table.remove(SnowflakeQueue, Index)
else
SnowFlake.CycleTick = Configuration.CycleLife
SnowFlake.Mode = 0
Index = Index + 1
end
elseif SnowFlake.Mode == 0 then
Flake.Transparency = (CycleTick/HalfLife)* MaxTransparency + (MaxTransparency)
Flake.CFrame = Flake.CFrame + SnowFlake.MoveRate
SnowFlake.CycleTick = CycleTick - 1
if SnowFlake.CycleTick <= 0 then
SnowFlake.Mode = 1
end
Index = Index + 1
elseif SnowFlake.Mode == 1 then
Flake.Transparency = (CycleTick/HalfLife)*MaxTransparency + (MaxTransparency)
Flake.CFrame = Flake.CFrame + SnowFlake.MoveRate
SnowFlake.CycleTick = CycleTick + 1
if SnowFlake.CycleTick >= HalfLife then
SnowFlake.Mode = 2
end
Index = Index + 1
end
end
end
local function MakeSnowFlake(Parent, InitialCFrame)
local FlakeSize = math.random(Configuration.SmallestFlakeSize, Configuration.LargestFlakeSize)/100
local Flake = Instance.new("Part", Parent)
Flake.Anchored = true;
Flake.CanCollide = false;
Flake.FormFactor = "Custom";
Flake.Size = Vector3.new(1, 1, 1)
Flake.Name = "SnowFlake";
Flake.BottomSurface = "Smooth";
Flake.CFrame = InitialCFrame
Flake.Transparency = 1;
local Mesh = Instance.new("SpecialMesh", Flake)
Mesh.MeshType = "FileMesh"
Mesh.MeshId = "http://www.roblox.com/asset/?id=1185246"
Mesh.TextureId = "http://www.roblox.com/asset/?id=1361097"
Mesh.VertexColor = Configuration.SnowColor;
Mesh.Scale = Vector3.new(FlakeSize, FlakeSize, FlakeSize)
local SnowFlake = {}
SnowFlake.Flake = Flake;
SnowFlake.CycleTick = Configuration.CycleLife
SnowFlake.CyclesLeft = math.random(Configuration.CyclesPerLifeMin, Configuration.CyclesPerLifeMax)
SnowFlake.MoveRate = GetSnowflakeMovement()
SnowFlake.Mode = 0
table.insert(SnowflakeQueue, SnowFlake)
end
local function CheckPlayer(Player)
return Player and Player:IsA("Player") and Player:IsDescendantOf(Players)
end
local function CheckCharacter(Player)
if CheckPlayer(Player) then
local Character = Player.Character;
if Character then
return Character.Parent
and Character:FindFirstChild("Humanoid")
and Character:FindFirstChild("HumanoidRootPart")
and Character:FindFirstChild("Torso")
and Character:FindFirstChild("Head")
and Character.Humanoid:IsA("Humanoid")
and Character.Head:IsA("BasePart")
and Character.Torso:IsA("BasePart")
and true
end
else
warn("[CheckCharacter] - Character Check failed!")
end
return nil
end
local FindPartOnRayWithIgnoreList = workspace.FindPartOnRayWithIgnoreList
local function AdvanceRaycast(RayTrace, IgnoreList, TransparencyThreshold, IgnoreCanCollideFalse, TerrainCellsAreCubes, MaximumCastCount, CustomCondition)
assert(type(MaximumCastCount) == "number", "MaximumCastCount is not a number")
assert(type(TransparencyThreshold) == "number", "TransparencyThreshold must be a number")
local ContinueCasting = true;
local CastCount = 0
local function CastAttempt(NewRayTrace)
if CastCount >= MaximumCastCount then
return
else
CastCount = CastCount + 1
end
local Object, Position = FindPartOnRayWithIgnoreList(workspace, NewRayTrace, IgnoreList, TerrainCellsAreCubes)
if Object and Position then
if CustomCondition and CustomCondition(Object, Position) then
return Object, Position
elseif IgnoreCanCollideFalse and Object.CanCollide == false then
IgnoreList[#IgnoreList+1] = Object
return CastAttempt(NewRayTrace)
elseif TransparencyThreshold and Object.Transparency >= TransparencyThreshold then
IgnoreList[#IgnoreList+1] = Object
return CastAttempt(NewRayTrace)
else
return Object, Position
end
else
return
end
end
local DirectionUnit = RayTrace.Direction.unit
local Magnitude = RayTrace.Direction.magnitude
local CastedMagnitude = 0
while CastedMagnitude < Magnitude do
local ToCastMagnitude = Magnitude - CastedMagnitude
if ToCastMagnitude > 999.5 then
ToCastMagnitude = 999
end
local WaysAlongPath = RayTrace.Origin + (DirectionUnit * CastedMagnitude)
local NewRayTrace = Ray.new(WaysAlongPath, DirectionUnit * ToCastMagnitude)
local Object, Position = CastAttempt(NewRayTrace)
if Object then
return Object, Position
end
CastedMagnitude = CastedMagnitude + ToCastMagnitude
if CastCount >= MaximumCastCount then
print("[AdvanceRaycast] - Reached maximum cast count @ " .. CastCount .. "; MaximumCastCount = " .. MaximumCastCount)
return nil
end
end
end
local SnowModel = GetSnowModel()
SnowModel:ClearAllChildren()
local LocalPlayer = Players.LocalPlayer
local LastValidPlace
local IgnoreList = {SnowModel, LocalPlayer.Character}
local LastClean = tick()
local function CleanIgnoreList()
if LastClean + 5 <= tick() then
IgnoreList = {SnowModel, LocalPlayer.Character}
LastClean = tick()
end
end
local function DrawRay(Ray, Color, Parent)
Parent = Parent or workspace
local NewPart = Instance.new("Part", Parent)
NewPart.FormFactor = "Custom"
NewPart.Size = Vector3.new(0.2, Ray.Direction.magnitude, 0.2)
local Center = Ray.Origin + Ray.Direction/2
NewPart.CFrame = CFrame.new(Center, Ray.Origin + Ray.Direction) * CFrame.Angles(math.pi/2, 0, 0)
NewPart.Anchored = true
NewPart.CanCollide = false
NewPart.Transparency = 0.5
NewPart.BrickColor = Color or BrickColor.new("Bright red")
NewPart.Name = "DrawnRay"
Instance.new("SpecialMesh", NewPart)
return NewPart
end
while true do
local Camera = workspace.CurrentCamera
if Camera then
local ExtensionRay = Ray.new(Camera.CoordinateFrame.p,
Camera.CoordinateFrame:vectorToWorldSpace(Vector3.new(0, 0, -Configuration.RangeZ))
)
local Hit, Position = AdvanceRaycast(ExtensionRay, IgnoreList, 0.001, true, true, 5)
if not Hit then
local NewRay = Ray.new((Camera.CoordinateFrame * CFrame.new(0, 0, -Configuration.RangeZ)).p, Vector3.new(0, 100, 0))
local Hit, Position = AdvanceRaycast(NewRay, IgnoreList, 0.001, true, true, 5)
if not Hit then
LastValidPlace = Camera.CoordinateFrame
end
end
if LastValidPlace then
for Index = 1, Configuration.SnowAmountFactor do
MakeSnowFlake(SnowModel, GetRandomSnowflakePosition(LastValidPlace, Camera.CoordinateFrame))
end
end
end
UpdateQueue()
CleanIgnoreList()
wait(0.03)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
Insert this into a local script and just put the local script into the StarterGui. I hope this helps. :)
Holy crap, lmfao xD
Huh? What's the matter?
You wrote this dude a book lmao
No,it's not. He can use (ctrl A and ctrl V) for copying and paste.
Really, Don't just post a nonchalant script, this is scripting helpers. NOT script makers. and this isn't even yours
I'm sorry, I just want to helps. I'll remove it. :|
@lmfaoxd Can I get a script for rain?