I made this script, when you click a button it spawns a car; when you die the car stays, but if you spawn a new car the old one is removed, but when I click the button the second time, it doesn't delete the old car, does this mean the "If deploymech then" isn't working? [Original script]
deploymech = script.Parent:FindFirstChild("DeployMech")
function onClicked()
print("Clicked!")
if deploymech then
print("about to remove!")
wait(1)
deploymech:remove()
end
end
script.Parent.Panel.ChooseMech.ClickDetector.MouseClick:connect(onClicked)
[Finished script]
function onClicked()
print("Clicked!")
if script.Parent.Panel.IsMechValue.Value == 0 then
local deploymech = script.Parent:FindFirstChild("DeployMech")
if deploymech then
print("about to remove!")
deploymech:remove()
end
end
end
script.Parent.Panel.ChooseMech.ClickDetector.MouseClick:connect(onClicked)
This might be an easy fix that I am over looking! Please help!!! Thank you!!! P.S This is a regular script

1 comment
Why are you using repeat?