Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Weather script loaded")
- --setup
- WeatherChange = "Random" --Amount of time in seconds before weather changes. Use String "Random" to set it to random.
- LocationX = 0
- LocationY = 400
- LocationZ = 0 --Location
- SizeX = 2048
- SizeY = 250
- SizeZ = 2048 --Size
- local CloudParticle = script.Parent.CloudParticle --Defines CloudParticle
- local CloudPart = script.Parent --Defines CloudPart
- local RainParticle = script.Parent.RainParticle
- script.Parent = workspace.CloudPart --Puts script into CloudPart
- math.randomseed( os.time() ) --Seeds math.random using OS time
- WeatherChange = math.random(10, 60)
- function WeatherChangeAlart ()
- Instance.new("Explosion", script.Parent)
- end
- function RandomWeatherChangeTime () --Function for Random WeatherChange Time
- if WeatherChange == "Random" then --checks if WeatherChange variable is set to random
- WeatherChange = math.random(10, 60) --Min/Max time until next WeatherChange
- end
- print ("time until next WeatherChange is: " .. WeatherChange)
- end
- --Cloud Direction Chooser
- function RandomCloudDirection ()
- print("Begin RandomCloudDirection Loop")
- CloudDirection = math.random(1, 4)--Randomly Generates number with numbers corrosponding to directions
- if CloudDirection == 1 then
- CloudParticle.EmissionDirection = "Front"
- WeatherChangeAlart()
- print("CloudDirection: Front")
- elseif CloudDirection == 2 then
- CloudParticle.EmissionDirection = "Back"
- WeatherChangeAlart()
- print("CloudDirection: Back")
- elseif CloudDirection == 3 then
- CloudParticle.EmissionDirection = "Left"
- WeatherChangeAlart()
- print("CloudDirection: Left")
- elseif CloudDirection == 4 then
- CloudParticle.EmissionDirection = "Right"
- WeatherChangeAlart()
- print("CloudDirection: Right")
- end
- print("End RandomCloudDirection Loop")
- end
- function Cloudiness () --Function to change cloudiness
- print ("Begin Cloudiness Loop")
- CloudParticle.Rate = math.random(0, 200) --Choose between Cloudiness of 0-100
- print ("Cloudiness: " .. CloudParticle.Rate) --display Cloudiness
- print ("end Cloudiness Loop")
- end
- function Lightning()
- Instance.new("Part", script.Parent)
- script.Parent.Part.Anchored = true
- print("Created LightingPart")
- local LightningPart = script.Parent.Part
- LightningPart.Position = Vector3.new(
- math.random(LocationX-(SizeX/2), LocationX+(SizeX/2)),
- LocationY,--Y postion doesn't really matter
- math.random(LocationZ-(SizeZ/2), LocationZ+(SizeZ/2))
- --Minium position for part is the location of the CloudPart minus half the size of the cloudpart,
- --Max postion is the location of the CloudPart plus half the size of the cloudpart
- )
- LightningPart.Material = "Neon"
- LightningPart.Color = Color3.fromRGB(255,255,255)
- end
- function precipitation()
- print ("Begin precipitation loop")
- if math.random(1, 4) == 4 then
- RainParticle.Enabled = true
- CloudParticle.Rate = 200
- CloudParticle.Color = ColorSequence.new(Color3.fromRGB(100,100,100))
- Lightning()
- print("precipitating")
- end
- print ("end precipitation loop")
- end
- function CloudColor()
- print ("Changing CloudColor")
- CloudParticle.Color = ColorSequence.new(Color3.fromRGB(200-CloudParticle.Rate/2,200-CloudParticle.Rate/2,200-CloudParticle.Rate/2 ))
- --changes color of the cloud based on how cloudy it is
- end
- --Script for CloudPart
- CloudPart.Name = "CloudPart" --Makes sure name is the part Cloud
- CloudPart.Anchored = true --Anchors part
- CloudPart.Position = Vector3.new(LocationX, 400, LocationZ) --Places it at location specified by the variable(for some reason the vars above doesnt actuall work so you are going to have to set them manually)
- print(LocationY)
- print (CloudPart.Position)
- CloudPart.Size = Vector3.new(SizeX, -100, SizeZ) --Sizes it to the dimensions specified by the variable
- CloudPart.CanCollide = false --removes colliders
- print("Part Created!")
- --Script for CloudParticle
- CloudParticle.Name = "CloudParticle" --Makes sure name is CloudParticle
- CloudParticle.Texture = "rbxassetid://258128463" --Fetches texture
- CloudParticle.Lifetime = NumberRange.new(WeatherChange,WeatherChange)
- CloudParticle.Size = NumberSequence.new(500)
- print("Particle Created!")
- --script for RainParticle
- RainParticle.Name = "RainParticle" --Makes sure name is RainParticle
- RainParticle.Texture = "rbxassetid://242967670" --Fetches texture
- RainParticle.Rate = 100000001504746621987668885504100000001504746621987668885504.000
- RainParticle.Enabled = false
- while true do
- print ("_________________________________________________")
- RandomCloudDirection()
- print("Changing Cloud Direction")
- Cloudiness ()
- print("Changing Cloudiness")
- RandomWeatherChangeTime()
- precipitation()
- print("Changing precipitation")
- CloudColor()
- wait(WeatherChange)
- end
Add Comment
Please, Sign In to add comment