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

Auto respawning script with a value doesn't work, why?

Asked by 5 years ago

So i want to make a script that will respawn a part (model = script.Parent.blocks) when the script.Parent.Ded.Value is equal to 0

Here what i did, but it doesn't work

local Spawner = script.Parent.PartSpawn
model = script.Parent.blocks
backup = model:clone() 
waitTime = 1 

function getvalue()
    areuthere = script.Parent.Ded.Value
end

getvalue()
if areuthere == 0 then  
wait(waitTime) 

model:remove() 

model = backup:clone() 
model.Position = Spawner.Position + Vector3.new(math.random(-Spawner.Size.x/2, Spawner.Size.x/2), math.random(0,10), math.random(-Spawner.Size.z/2,Spawner.Size.z/2))
model.Parent = script.Parent
model:makeJoints() 
end 



Please help, thanks

0
why are you using a function to get the value? dont do that DinozCreates 1070 — 5y
0
I tried several ways but it did not work dingding2002 14 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

First of all, if you are trying to make it spawn bricks or models constantly, you need to position it where you want it to spawn and put it in replicated storage so it can be cloned.


local Spawner = script.Parent.PartSpawn model = game.ReplicatedStorage.blocks backup = model:clone() waitTime = 1 while true do if model.Location = game.Workspace then model:clone:(false) else model:clone:(true)

Also, why did you make the "waittime" a variable when you could just do wait(1)?

0
It will always respawn even if the value is not equal to zero dingding2002 14 — 5y
Ad

Answer this question