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

spawning in object based on value in "if" statement not working?

so im trying to make a boss appear when the wave value reaches a certain number. but nothing happens and my output isnt giving me any error messages. what gives?

if game.ReplicatedStorage.Values.Wave.Value == 2 then
	game.ReplicatedStorage.BOSS.Zombie:Clone().Parent = game.Workspace
end

1 answer

✓ Accepted answer

Okay so I think I have fixed your script.

:GetPropertyChangedSignal is very useful when using values.

every time the value updates for example it increases by one, the event will fire.``

local Wave = game.ReplicatedStorage:WaitForChild("Values").Wave

local clone = game.ReplicatedStorage.BOSS.Zombie:Clone()

Wave:GetPropertyChangedSignal("Value"):Connect(function()
	if Wave.Value == 2 then
		clone.Parent = game.Workspace
	end
end)

developer hub link to :GetPropertyChangedSignal

https://developer.roblox.com/en-us/api-reference/function/Instance/GetPropertyChangedSignal

I have not answered to many questions before forgive me for formatting errors please

4 comments

0

it apears the link doesent work if you google it it should pop up if you need it ^

0

thank you so much! this worked perfectly.

0

now, if i wanted to have the object spawn every 6 waves, then how would i go about that? just "If wave.Value == wave.Value /6"?

0

yeah

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