Hello again, I’m wanting to make it so that the rain droplets delete themselves after a specified time has passed, but I keep getting an ‘Expected ( to close ) at line 22, got eof’ error.
Here’s my code as it stands atm:
local Droplets = 0
local ground = game.Workspace.Ground
while true do
local Rain = Instance.new ("Part")
if Droplets >= 2000 then
break
end
local RNGX = math.random(1,99)
local RNGZ = math.random(1,163)
Droplets = Droplets + 1
Rain.Parent = game.Workspace
Rain.Name = "RainDrop"
Rain.Size = Vector3.new(.5,1.5,.5)
Rain.Transparency = .5
Rain.CanCollide = true
Rain.BrickColor = BrickColor.new("Electric blue")
Rain.Anchored = false
Rain.Position = Vector3.new(RNGX,13,RNGZ)
Rain.Material = "SmoothPlastic"
wait(1.5)
ground.Touched:Connect(function(hit)
if Rain then
wait(2)
Rain:Destroy()
end
You have two opening parentheses on the first line here, as is typical for a connected function. You don’t do end), though, so you just have a parenthesis that never closes. You’re also missing multiple ends.
I got this code w/o errors, but I’ve noticed that sometimes I have to put a ) in a spot that seems like it wouldn’t make sense in (in this case, line 28), is this usually a result of typing the code structure incorrectly or is it normal?
local Droplets = 0
local ground = game.Workspace.Ground
while true do
local Rain = Instance.new ("Part")
if Droplets >= 2000 then
break
end
local RNGX = math.random(1,99)
local RNGZ = math.random(1,163)
Droplets = Droplets + 1
Rain.Parent = game.Workspace
Rain.Name = "RainDrop"
Rain.Size = Vector3.new(.5,1.5,.5)
Rain.Transparency = .5
Rain.CanCollide = true
Rain.BrickColor = BrickColor.new("Electric blue")
Rain.Anchored = false
Rain.Position = Vector3.new(RNGX,13,RNGZ)
Rain.Material = "SmoothPlastic"
wait(1.5)
ground.Touched:Connect(function(hit)
if Rain then
wait(2)
Rain:Destroy()
end
end
)
end
That returns no errors, but now it’s not destroying the part like it’s meant to. I tried making it a function and moving the variables for the rain and rain parent out of the while loop, but the output says that the property is locked and = to null. Before I did that though, I noticed that it now underlines ‘Rain’ as an unknown global in the ground.touched function.