I’m making a simple script that when the player joins the game a set of images should be shown on the screen. I’m using the visibility boolean to try and make it possible but it doesn’t show up. Here is my code:
you should probably put this inside a LocalScript instead of a PlayerAdded function, You should also wait for the object as you are firing the code when the Player joins the game and not when the Item is added to the , also, this is very inefficient way of doing this, you should instead do:
local gui = player.PlayerGui:WaitForChild("ImageCutscenes") -- waits for object
for index = 1,#ImageCutscenes:GetChildren() do -- fires for the number of objects within the ScreenGui
pcall(function() -- This is so it doesn't cause errors to the code
gui[i].Visible = true
gui[i-1].Visible = false
end)
task.wait(5) --improved version of wait()
end
I fixed some stuff up and put it in a local script but it still doesn’t fire:
local player = game.Players.LocalPlayer
local gui = player.PlayerGui:WaitForChild("ImageCutscenes") -- waits for object
for index = 1,#gui:GetChildren() do -- fires for the number of objects within the ScreenGui
pcall(function() -- This is so it doesn't cause errors to the code
gui[index].Visible = true
gui[index-1].Visible = false
end)
task.wait(5) --improved version of wait()
end