#obstacle.IsLoaded never loads

1 messages · Page 1 of 1 (latest)

surreal raven
#

localscript - for GUI

local function gameLoop(player)
    if playing == true then
        local obstacle = Instance.new("ImageLabel")
        obstacle.Image = "rbxassetid://104767996247335"
        local randomNumber = math.random()
        obstacle.Name = "Obstacle"
        obstacle.Size = UDim2.fromScale(0.2, 0.3)
        obstacle.Position = UDim2.fromScale(1, randomNumber)
        obstacle.BackgroundTransparency = 1
        obstacle.ZIndex = 2
        local obstacleMove = TweenService:Create(obstacle, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Position = UDim2.fromScale(-0.3, randomNumber)})
        obstacle.Parent = kittyBounce.Game
        while not obstacle.IsLoaded do      --Should wait til the image has finished loading in.
            task.wait()
        end
        obstacleMove:Play()
        task.wait(0.525)

i'm making a GUI arcade game - basically every second an obstacle should pass from right to left across the screen but the image takes a second to load making the obstacle load up half way across the screen sometimes giving you no time to dodge it but the game never starts when i try waiting for the IsLoaded variable.

tribal crystal
#

game.ContentProvider:PreloadAsync({obstacle})

surreal raven
#

okk cheers

surreal raven
#

btw that worked marking as solved - sorry i didnt get back to you i had irl stuff to do cheers for the help :D