Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

why are you using a function to get the value? dont do that

0

I tried several ways but it did not work

1 answer

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)?

1 comment

0

It will always respawn even if the value is not equal to zero

This discussion is preserved as it was. New answers, comments, and votes are closed.