So I am making a system where you can build snow forts and structures n stuff.
I’m trying to make it so you can cancel the building process by unequipping the tool or by getting hit with a snowball. And I can’t seem to figure out how I can do this without this one problem.
The problem is that when you start building the structure then cancel it then start building it again, the character stops in the middle of building it and you can move around while the structure is still being built.
My code:
local isBuilding = false
local Cancelled = false
function onBuild(plr,Snowprint)
isBuilding = true
local moduleName = string.gsub(Snowprint.Name," ","")
module[moduleName](plr,plr,currentStructure)
if not Cancelled then
isBuilding = false
currentStructure = nil
if anim then anim:Stop() end
anim = nil
return true
else
Cancelled = false
return false
end
end
function onCancel(plr)
if isBuilding then
Cancelled = true
if isBuilding == false then
Cancelled = false
end
end
end
Any help is appreciated.