Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Removing FillBlock() not working. What is the proper way to remove terrain with a script?

Asked by
Oly_Xr 2
4 years ago

Hello! So I am trying to remove this piece of water (terrain) when a player uses a click detector, but when I click, it gives me this message: "attempt to index upvalue 'water' (a nil value)" I tought that it works like an Instance.new, but I am probably wrong, well, here's the code:

local water = game.Workspace.Terrain:FillBlock(game.Workspace.WaterPart.CFrame, game.Workspace.WaterPart.Size, Enum.Material.Water)

script.Parent.ClickDetector.MouseClick:Connect(function()
water:Destroy()
end)

Thank you.

1 answer

Log in to vote
0
Answered by
Oly_Xr 2
4 years ago
Edited 4 years ago

I fixed it. I forgot that you were able to fill areas with Enum.Material.Air.

Ad

Answer this question