the variable Framee
is not is not updating and i don't know why can you please help me here is code
player.Backpack.ChildAdded:connect(function(instance) local name=instance.Name if name==game.Lighting.E:GetChildren()[1].Name or name==game.Lighting.Q:GetChildren()[1].Name or name==game.Lighting.R:GetChildren()[1].Name or name==game.Lighting.F:GetChildren()[1].Name or name==game.Lighting.G:GetChildren()[1].Name then print(instance.Name .. " added to the backpack by item Clone") else print(instance.Name .. " " .. Framee) player.PlayerGui.Invintory[Framee].Frame1.Visible = true local FrameNumber = FrameNumber + 1 local Framee = "Frame" .. FrameNumber end end)
can anyone tell my why
The string change on line 9 requires a tostring() statement:
Framee="Frame"..tostring(FrameNumber)
Hope this helped!
local Framee = "Frame" .. FrameNumber is only updating for that specific function run through. This essentially means that the variable is worthless since it is defined and then forgotten as it is enclosed inside the function. This is the same for FrameNumber. To make it a variable seen by the entire script, predefine it outside of the function like this:
local FrameNumber = 0 local Framee = "Frame"..FrameNumber player.Backpack.ChildAdded:connect(function(instance) local name=instance.Name if name==game.Lighting.E:GetChildren()[1].Name or name==game.Lighting.Q:GetChildren()[1].Name or name==game.Lighting.R:GetChildren()[1].Name or name==game.Lighting.F:GetChildren()[1].Name or name==game.Lighting.G:GetChildren()[1].Name then print(instance.Name .. " added to the backpack by item Clone") else print(instance.Name .. " " .. Framee) player.PlayerGui.Invintory[Framee].Frame1.Visible = true FrameNumber = FrameNumber + 1 Framee = "Frame" .. FrameNumber end end)