Pkxdjosh56_roblox

Roblox fog spawner script

Sep 15th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. -- Realistic Fog Spawner Script (Client-Sided)
  2.  
  3. -- Configuration
  4. local FogColor = Color3.fromRGB(125, 125, 125) -- Set the color of the fog
  5. local FogDensity = 0.5 -- Set the density of the fog (0 = no fog, 1 = solid fog)
  6. local FogSize = 50 -- Set the size of the fog
  7. local FogTransparency = 0.5 -- Set the transparency of the fog particles (0 = fully opaque, 1 = fully transparent)
  8.  
  9. -- Create tool
  10. local tool = Instance.new("Tool")
  11. tool.Name = "Fog Spawner"
  12. tool.RequiresHandle = false
  13. tool.Parent = game.Players.LocalPlayer.Backpack
  14.  
  15. -- Function to create fog at a specific position
  16. local function createFog(position)
  17. local fog = Instance.new("Part")
  18. fog.Name = "Fog"
  19. fog.Size = Vector3.new(FogSize, FogSize, FogSize)
  20. fog.Transparency = 1 -- Set initial transparency to 1 for the ParticleEmitter
  21. fog.CanCollide = false
  22. fog.Anchored = true
  23. fog.CFrame = CFrame.new(position)
  24. fog.Parent = workspace
  25.  
  26. local fogEmitter = Instance.new("ParticleEmitter")
  27. fogEmitter.Name = "FogEmitter"
  28. fogEmitter.Parent = fog
  29. fogEmitter.Enabled = true
  30. fogEmitter.Rate = 100
  31. fogEmitter.Lifetime = NumberRange.new(10, 15)
  32. fogEmitter.Speed = NumberRange.new(1, 5)
  33. fogEmitter.VelocitySpread = 180
  34. fogEmitter.Rotation = NumberRange.new(0, 360)
  35. fogEmitter.RotSpeed = NumberRange.new(-5, 5)
  36. fogEmitter.Size = NumberSequence.new(FogSize)
  37. fogEmitter.Transparency = NumberSequence.new(FogTransparency)
  38. fogEmitter.Acceleration = Vector3.new(0, -5, 0)
  39. fogEmitter.Color = ColorSequence.new(FogColor)
  40. end
  41.  
  42. -- Function to handle mouse click
  43. local function onMouseClick()
  44. if tool.Parent == game.Players.LocalPlayer.Character then
  45. local mouse = game.Players.LocalPlayer:GetMouse()
  46. local position = mouse.Hit.Position
  47. createFog(position)
  48. end
  49. end
  50.  
  51. -- Equip the tool when it is added to the backpack
  52. tool.Equipped:Connect(function()
  53. local mouse = game.Players.LocalPlayer:GetMouse()
  54. mouse.Button1Down:Connect(onMouseClick)
  55. end)
  56.  
  57. -- Unequip the tool when it is removed from the backpack
  58. tool.Unequipped:Connect(function()
  59. local mouse = game.Players.LocalPlayer:GetMouse()
  60. mouse.Button1Down:Disconnect()
  61. end)
Add Comment
Please, Sign In to add comment