so im doing a tycoon, and its a multistage tycoon, so ive got wood walls u will buy in the very beginning which are small, then a little bit in you unlock stone walls which cover a larger area
im intending it to remove the wood walls and add the stone walls, well right now it adds the stone but doesnt remove the wood, tho it does remove the wood wall if i left it active, but if the wood wall is spawned in with a tycoon, then i attemt to remove it with the stone wall button it doesnt remove it
here is both scripts, any help figuring out the problem is appreciated :)
WOOD WALL SCRIPT
------------------------------------------------------------------------------------------------------------------------- model = script.Parent.Parent.Parent.WoodAge.WoodWalls Upgradecost = 0 ------------------------------------------------------------------------------------------------------------------------- upgradeStuff = model:clone() wait(1) model:remove() owner = script.Parent.Parent.Parent.OwnerName local ting = 0 function onTouched(clicked) hit = clicked.Character.Head if ting == 0 then ting = 1 check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then if hit.Parent.Name == owner.Value then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") if stats ~= nil then local cash = stats:findFirstChild("Gold") if cash.Value > (Upgradecost-1) then cash.Value = cash.Value - Upgradecost upgradeStuff.Parent = script.Parent.Parent.Parent script.Parent.Parent:remove() end end end end ting = 0 end end script.Parent.ClickDetector.MouseClick:connect(onTouched)
STONE WALL SCRIPT
------------------------------------------------------------------------------------------------------------------------- Wall = script.Parent.Parent.Parent.WoodAge.WoodWalls model = script.Parent.Parent.Parent.MidStone.SmallCastle Upgradecost = 0 ------------------------------------------------------------------------------------------------------------------------- upgradeStuff = model:clone() wait(1) model:remove() owner = script.Parent.Parent.Parent.OwnerName local ting = 0 function onTouched(clicked) hit = clicked.Character.Head if ting == 0 then ting = 1 check = hit.Parent:FindFirstChild("Humanoid") if check ~= nil then if hit.Parent.Name == owner.Value then local user = game.Players:GetPlayerFromCharacter(hit.Parent) local stats = user:findFirstChild("leaderstats") if stats ~= nil then local cash = stats:findFirstChild("Gold") if cash.Value > (Upgradecost-1) then cash.Value = cash.Value - Upgradecost upgradeStuff.Parent = script.Parent.Parent.Parent script.Parent.Parent:remove() Wall:remove() -- this is where i try to remove the wooden wall end end end end ting = 0 end end script.Parent.ClickDetector.MouseClick:connect(onTouched)
to make life easier why dont you just keep the same wall increase the size change the offset so it doesnt bleed through any other blocks and change its properties.
Try using model:Destroy()
instead?
Remove is horrible, and never works. What you want to do is replace "remove()" with "Destroy()".
-- Destroy() must be capitalized correctly. -- Destroy() is about the same as remove(), but better. -- Destroy() ftw. game.Workspace.Part:Destroy()