I'm making a real time strategy game where units can be created/destroyed ect... I need help with a script I'm trying to make
Off=false
function Click1 ()
if workspace.Units.SoldierNumber.Value == 0 and Off == false then
local B = game.ReplicatedStorage.Grunt0
local clone = B:Clone()
clone:Clone().Parent = game.workspace.Units
workspace.Units.Grunt0:MakeJoints()
workspace.Units.SoldierNumber.Value = workspace.Units.SoldierNumber.Value + 1
--loop below to change names??
workspace.Units.Grunt0.Name = "Grunt1"
end
end
----------------------------------------------------------------------------------------------------------------------------------
--Remakes the troop if its dead
if workspace.Units.Grunt1.Alive.Value == false then do
local B = game.ReplicatedStorage.Grunt0
local clone = B:Clone()
clone:Clone().Parent = game.workspace.Units
workspace.Units.Grunt0:MakeJoints()
workspace.Units.SoldierNumber.Value = workspace.Units.SoldierNumber.Value + 1
workspace.Units.Grunt0.Name = "Grunt1"
print (GruntNumber[1])
--Creating = 2
end
end
I need this function to repeat but change the name of the troop in the process and check if one like it is alive already. I want it to spawn "Grunt(# here)" in then check if it is dead by using a Value( there is two inside the troop, Alive or Dead). If it is dead I want it remake the troop that is dead in order, then continue on making the next troop if the Grunt is still alive.
Example: If I spawn two troops in, Grunt1 and Grunt2 then later on Grunt1 dies I want Grunt1 to be built before Grunt3 is built.
Any help will be Appreciated! Thank You

4 comments
Wow! Thank you very much I'll try it and get back to you about how it is working
Cool! If you need to PM me, send a message to EmeraldSlash.
Alright I ran into a problem and its too long to post in this tiny comment box but Ill send you a PM in a day or two after I get back from vacation
Ok.