You have Bool acting as a sort of debounce for this function.
You require that Bool is false (ie not Bool is true) in order for your script to run -- but once you've made on blade, you set Bool to true (and nothing sets it to false later).
I'm guessing what you meant to do was to disable making new ones while it's changing from black to green -- and then enable it again.
enabled = true
script.Parent.ClickDetector.MouseClick:connect(function()
if enabled then
local grass = game.Lighting.Grass:Clone()
grass.Parent = game.Workspace
script.Parent.BrickColor = BrickColor.new("Really black")
enabled = false
wait(1)
script.Parent.BrickColor = BrickColor.new("Dark green")
enabled = true
end
end)
If you just want to know if there's already a part named "Grass" in the workspace, there's no need for a debounce at all:
script.Parent.ClickDetector.MouseClick:connect(function()
if not workspace:FindFirstChild("Grass") then
local grass = game.Lighting.Grass:Clone()
grass.Parent = game.Workspace
script.Parent.BrickColor = BrickColor.new("Really black")
wait(1)
script.Parent.BrickColor = BrickColor.new("Dark green")
end
end)
4 comments
Thank you
But now when I click it I can click it over and over and more "Grass" will spawn. is there a way to make it work like this without any more grass spawning until it is out of Workspace?
You should explain what you want in the first place when you ask questions -- we need to know what you're thinking, not just be given code and told there's a problem.
The title is.. sorta accurate. Just incorrect termonology.