Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Realistic Fog Spawner Script (Client-Sided)
- -- Configuration
- local FogColor = Color3.fromRGB(125, 125, 125) -- Set the color of the fog
- local FogDensity = 0.5 -- Set the density of the fog (0 = no fog, 1 = solid fog)
- local FogSize = 50 -- Set the size of the fog
- local FogTransparency = 0.5 -- Set the transparency of the fog particles (0 = fully opaque, 1 = fully transparent)
- -- Create tool
- local tool = Instance.new("Tool")
- tool.Name = "Fog Spawner"
- tool.RequiresHandle = false
- tool.Parent = game.Players.LocalPlayer.Backpack
- -- Function to create fog at a specific position
- local function createFog(position)
- local fog = Instance.new("Part")
- fog.Name = "Fog"
- fog.Size = Vector3.new(FogSize, FogSize, FogSize)
- fog.Transparency = 1 -- Set initial transparency to 1 for the ParticleEmitter
- fog.CanCollide = false
- fog.Anchored = true
- fog.CFrame = CFrame.new(position)
- fog.Parent = workspace
- local fogEmitter = Instance.new("ParticleEmitter")
- fogEmitter.Name = "FogEmitter"
- fogEmitter.Parent = fog
- fogEmitter.Enabled = true
- fogEmitter.Rate = 100
- fogEmitter.Lifetime = NumberRange.new(10, 15)
- fogEmitter.Speed = NumberRange.new(1, 5)
- fogEmitter.VelocitySpread = 180
- fogEmitter.Rotation = NumberRange.new(0, 360)
- fogEmitter.RotSpeed = NumberRange.new(-5, 5)
- fogEmitter.Size = NumberSequence.new(FogSize)
- fogEmitter.Transparency = NumberSequence.new(FogTransparency)
- fogEmitter.Acceleration = Vector3.new(0, -5, 0)
- fogEmitter.Color = ColorSequence.new(FogColor)
- end
- -- Function to handle mouse click
- local function onMouseClick()
- if tool.Parent == game.Players.LocalPlayer.Character then
- local mouse = game.Players.LocalPlayer:GetMouse()
- local position = mouse.Hit.Position
- createFog(position)
- end
- end
- -- Equip the tool when it is added to the backpack
- tool.Equipped:Connect(function()
- local mouse = game.Players.LocalPlayer:GetMouse()
- mouse.Button1Down:Connect(onMouseClick)
- end)
- -- Unequip the tool when it is removed from the backpack
- tool.Unequipped:Connect(function()
- local mouse = game.Players.LocalPlayer:GetMouse()
- mouse.Button1Down:Disconnect()
- end)
Add Comment
Please, Sign In to add comment