Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need help with this error I'm only getting on Online mode...?

Asked by
KarlXYZ 120
10 years ago

Hi there,

I've made this script for an intro GUI when a player joins the game, the only thing that's not working properly is the variables... The script works perfectly while testing it on Play Solo, but while testing on Online mode, it gives me an error:

'arrowZL is not a valid member of ScreenGUI'

It then references to the script's location inside my PlayerGUI then inside the ScreenGUI that I renamed.

Even after resetting in-game, it still occurs and gives the same error. No GUIs appear in-game at all.

Apologies for the length of the script, I thought it was necessary if I was going to get any help whatsoever with this. All of this is contained within a local script.

firstZ = script.Parent.firstZ
secondZ = script.Parent.secondZ
arrowZL = script.Parent.arrowZL
arrowZR = script.Parent.arrowZR
openbool = script.Parent.open
rip = script.Parent.rip
player = game.Players.LocalPlayer

Assets = {155660360,155660378,155670319}

for _, asset in ipairs(Assets) do
     Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end

function load()
    wait(10)
    firstZ:TweenPosition(UDim2.new(0.5, -50, 0.5, -50), "Out", "Quart", 4)
    secondZ:TweenPosition(UDim2.new(0.5, -50, 0.5, -50), "Out", "Quart", 4)
    wait(6)
    firstZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 4)
    secondZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 4)
    wait(4)
    arrowZR.Visible = true
    arrowZL.Visible = true
    arrowZR:TweenPosition(UDim2.new(0.5, 52, 0.08, -12), "Out", "Quart", 1.5)
    arrowZL:TweenPosition(UDim2.new(0.5, -75, 0.08, -12), "Out", "Quart", 1.5)
end

function move()
    if openbool.Value == false and rip.Value == false then
        rip.Value = true
        firstZ:TweenPosition(UDim2.new(0.5, -350, 0.08, -50), "Out", "Quart", 2.5)
        secondZ:TweenPosition(UDim2.new(0.5, 250, 0.08, -50), "Out", "Quart", 2.5)
        arrowZR:TweenPosition(UDim2.new(0.5, 352, 0.08, -12), "Out", "Quart", 2.5)
        arrowZL:TweenPosition(UDim2.new(0.5, -375, 0.08, -12), "Out", "Quart", 2.5)
        repeat
            wait()
            arrowZR.Rotation = arrowZR.Rotation + 2
            arrowZL.Rotation = arrowZL.Rotation - 2
        until arrowZR.Rotation == 180 and arrowZL.Rotation == 0
        rip.Value = false
        openbool.Value = true
    else if openbool.Value == true and rip.Value == false then
        rip.Value = true
        firstZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 2.5)
        secondZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 2.5)
        arrowZR:TweenPosition(UDim2.new(0.5, 52, 0.08, -12), "Out", "Quart", 2.5)
        arrowZL:TweenPosition(UDim2.new(0.5, -75, 0.08, -12), "Out", "Quart", 2.5)
        repeat
            wait()
            arrowZR.Rotation = arrowZR.Rotation - 2
            arrowZL.Rotation = arrowZL.Rotation + 2
        until arrowZR.Rotation == 0 and arrowZL.Rotation == 180
        rip.Value = false
        openbool.Value = false
    end
    end
end

load()

arrowZR.MouseButton1Click:connect(move)
arrowZL.MouseButton1Click:connect(move)
0
The most common cause for these sorts of errors in Online Mode is that the Instances you want haven't initialised yet, i.e. they don't exist. You should use a combination of wait() and FindFirstChild to delay the start of your script until they do exist ;) duckwit 1404 — 10y

1 answer

Log in to vote
2
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago

They aren't there yet.

firstZ = script.Parent:WaitForChild("firstZ")
secondZ = script.Parent:WaitForChild("secondZ")
arrowZL = script.Parent:WaitForChild("arrowZL")
arrowZR = script.Parent:WaitForChild("arrowZR")
openbool =  script.Parent:WaitForChild("open")
rip = script.Parent:WaitForChild("rip")
player = game.Players.LocalPlayer

print("Ready to go")

Assets = {155660360,155660378,155670319}

for _, asset in ipairs(Assets) do
     Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset)
end

function load()
    wait(10)
    firstZ:TweenPosition(UDim2.new(0.5, -50, 0.5, -50), "Out", "Quart", 4)
    secondZ:TweenPosition(UDim2.new(0.5, -50, 0.5, -50), "Out", "Quart", 4)
    wait(6)
    firstZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 4)
    secondZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 4)
    wait(4)
    arrowZR.Visible = true
    arrowZL.Visible = true
    arrowZR:TweenPosition(UDim2.new(0.5, 52, 0.08, -12), "Out", "Quart", 1.5)
    arrowZL:TweenPosition(UDim2.new(0.5, -75, 0.08, -12), "Out", "Quart", 1.5)
end

function move()
    if openbool.Value == false and rip.Value == false then
        rip.Value = true
        firstZ:TweenPosition(UDim2.new(0.5, -350, 0.08, -50), "Out", "Quart", 2.5)
        secondZ:TweenPosition(UDim2.new(0.5, 250, 0.08, -50), "Out", "Quart", 2.5)
        arrowZR:TweenPosition(UDim2.new(0.5, 352, 0.08, -12), "Out", "Quart", 2.5)
        arrowZL:TweenPosition(UDim2.new(0.5, -375, 0.08, -12), "Out", "Quart", 2.5)
        repeat
            wait()
            arrowZR.Rotation = arrowZR.Rotation + 2
            arrowZL.Rotation = arrowZL.Rotation - 2
        until arrowZR.Rotation == 180 and arrowZL.Rotation == 0
        rip.Value = false
        openbool.Value = true
    else if openbool.Value == true and rip.Value == false then
        rip.Value = true
        firstZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 2.5)
        secondZ:TweenPosition(UDim2.new(0.5, -50, 0.08, -50), "Out", "Quart", 2.5)
        arrowZR:TweenPosition(UDim2.new(0.5, 52, 0.08, -12), "Out", "Quart", 2.5)
        arrowZL:TweenPosition(UDim2.new(0.5, -75, 0.08, -12), "Out", "Quart", 2.5)
        repeat
            wait()
            arrowZR.Rotation = arrowZR.Rotation - 2
            arrowZL.Rotation = arrowZL.Rotation + 2
        until arrowZR.Rotation == 0 and arrowZL.Rotation == 180
        rip.Value = false
        openbool.Value = false
    end
    end
end

load()

arrowZR.MouseButton1Click:connect(move)
arrowZL.MouseButton1Click:connect(move)

0
Wow, just a simple fix... Thanks for the quick answer. :) KarlXYZ 120 — 10y
Ad

Answer this question