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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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

0
it apears the link doesent work if you google it it should pop up if you need it ^ MPforfun 91 — 4y
0
thank you so much! this worked perfectly. nick2222 20 — 4y
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"? nick2222 20 — 4y
0
yeah MPforfun 91 — 4y
Ad

Answer this question