• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


08 Jan, 2025

Updated at 20 Jan, 2025

If value == nil not working

I am making a tycoon game and in my script, I implemented this if statement

if Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name].ID ~= Button.Name then

The output said: 19:15:06.753 Workspace.Tycoons.Plots.Template.Objects.Buttons.Button Executor:20: attempt to index nil with 'ID' - Server - Button Executor:20
The script returned that the value was nil (I believe so), so I tried another way to execute this code:

if Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name].ID == nil or Data.Tycoon.Floors[Floor.Name].Buttons[Button.Name].ID ~= Button.Name then

This is nerve-racking, I wrote that if the script returns nil, then the piece of line underneath it will execute, but instead it gave me again an error output, when I literally just said that the code will continue if it returns nil! I’ve been working on this issue for hours and I couldn’t find a single solution. Even my friend of mine was experiencing the same issue! Please, if anyone in this community knows the answer, I’d love you to tell me :pleading_face:. Many thanks for considering my request.

1 post - 1 participant

Read full topic