For example if you were developing a obby game, each stage would be named after the number the stage represents like stage 1 would be named 1. I tried to made a script that would take the stage of the player then find it in the workspace but don't understand what i did wrong in this script that makes error. ERROR:attempt to index upvalue 'f' (a nil value) - line 7
local player = game.Players.LocalPlayer local ls = player.leaderstats local Stage = ls.Stage local f = game.Workspace:FindFirstChild(Stage.Value) Stage.Changed:connect(function() f.BrickColor = BrickColor.new("Bright red") print(Stage.Value) end)
You can do local f = game.Workspace:FindFirstChild(tostring(Stage.Value))
Tell me if it works!
Okay so print the f variable by using print(f) before you try to set the brick color, if it comes up as nil then print Stage.Value, if it comes up as nil make sure Stage.Value is properly defined, if it does not come up as nil and comes up with the number you want make sure there is a part in workspace Called EXACTLY what the Int Value prints.