Cant localise variable in an if statement

In my game the characters can throw a fireball wow and the fireball changes depending on their stat. But when i try to do

if player.Stat.Value >= 10^21 then local fireball = game.ReplicatedStorage.Fireballs.Sx:Clone()
elseif player.Stat.Value >= 10^18 then local fireball = game.ReplicatedStorage.Fireballs.Qi:Clone()

etc.
it doesnt localise the fireball. How can i make this work. I dont want to copy and paste the entire code for 7 times.

Guys pls. Am i supposed to create a string value in player backpack and do game.ReplicatedStorage.Fireballs[StringValue.Value]:Clone()
with a scirpt inside the string value updating every second.

actually i can try it. It can work.

You can declare the local variable beforehand and assign the value in the if statement afterwards:

local fireball

if player.Stat.Value >= 10^21 then
    fireball = game.ReplicatedStorage.Fireballs.Sx:Clone()
elseif player.Stat.Value >= 10^18 then
    fireball = game.ReplicatedStorage.Fireballs.Qi:Clone()
end
1 Like

if player.Stat.Value

It should be if player.Stat.fireball

No… Player has a number value which is Right in player. and fireballs are in a folder in replicatedstorage.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.