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

Why isn't my elseif statement functioning properly?

Hello!

I am wondering why my elseIf statement isn't working correctly. As, when the value is set at 0, it prints out Hi. However, when the value is set at 1, and I click on my gui. It does not print anything at all! I would appreciate some help. As I have spend an hour on this and can't seem to figure it out.

local Gui = script.Parent.Picture

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Event = ReplicatedStorage:WaitForChild("Events").SaveDataReturn



Gui.MouseButton1Down:Connect(function()

Event:InvokeServer()



local Value = ReplicatedStorage.Return.SaveData



if Value == 0 then

print("Hi")

elseif Value == 1 then

print("Tween")

end





end)

1 comment

0

I think on line 15 you might want to change SaveData to SaveData.Value see if that fixes it, or try making it into 2 if statements

1 answer

✓ Accepted answer

On line 15 you have put

local Value = ReplicatedStorage.Return.SaveData

If ReplicatedStorage.Return.SaveData is a Value object then instead of that you must place:

local Value = ReplicatedStorage.Return.SaveData.Value

If its not that, then please give information on what exactly is ReplicatedStorage.Return.SaveData so I may help you.

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