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

How can I fix my frame script that does multiple things at a time?

Asked by 4 years ago

So I have a script that is in a Frame named Frame2 due to me having multiple Frames, and the Script is in a local script, and there are no errors the developer counsel from it.

---Script---

if script.Parent.Visible == true then
    script.Parent.TextButton1.Visible = false
    script.Parent.TextButton2.Visible = false
    script.Parent.TextButton3.Visible = false
    script.Parent.TextButton4.Visible = false
    script.Parent.TextButton5.Visible = false
if  script.Parent.ImageLabel1.Position == {0.358, 0},{0.303, 0} then
    wait(1)
    script.Parent.ImageLabel1.Position = {0.358, 0},{-0, 0}
if  script.Parent.TextLabel1.Position = {0.523, 0},{0.605, 0} then
    wait(1)
    script.Parent.TextLabel1.Position = {0.521, 0},{0.305, 0}
if  script.Parent.TextLabel2.Position = {0.523, 0},{0.604, 0} then
    wait(1)
    script.Parent.TextLabel2.Position = {0.521, 0},{0.304, 0}
if  script.Parent.TextButton1.Visible == false then
    wait(1)
    script.Parent.TextButton1.Visible == true
if  script.Parent.TextButton2.Visible == false then
    wait(1)
    script.Parent.TextButton2.Visible == true
if  script.Parent.TextButton3.Visible == false then
    wait(1)
    script.Parent.TextButton3.Visible == true
if  script.Parent.TextButton4.Visible == false then
    wait(1)
    script.Parent.TextButton4.Visible == true
if  script.Parent.TextButton5.Visible == false then
    wait(1)
    script.Parent.TextButton6.Visible == true
end
end
end  
end
end
end
end
end
end

I know it's not that good...but I don't know what I did wrong in it.

3 answers

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago
  1. You definitely had errors in the output
  2. You have to compare GUI Positions and Sizes with UDim2.new()
  3. Some of your numbers were -0
  4. If you're comparing something, use ==
    1. if you're setting something, use =

May still not work, not sure your if statements should be sub indexed like you have them now.


local root = script.Parent local Objects = { ['ImageLabel1'] = root:WaitForChild("ImageLabel1"); ['TextButton1'] = root:WaitForChild("TextButton1"); ['TextButton2'] = root:WaitForChild("TextButton2"); ['TextButton3'] = root:WaitForChild("TextButton3"); ['TextButton4'] = root:WaitForChild("TextButton4"); ['TextButton5'] = root:WaitForChild("TextButton5"); ['TextButton6'] = root:WaitForChild("TextButton6"); ['TextLabel1'] = root:WaitForChild("TextLabel1"); ['TextLabel2'] = root:WaitForChild("TextLabel2"); } if root.Visible then for i,v in pairs(Objects) do if v.ClassName == 'TextButton' and v.Name ~= 'TextButton6' then v.Visible = false end end if Objects.ImageLabel1.Position == UDim2.new(0.358, 0,0.303, 0) then wait(1) Objects.ImageLabel1.Position = UDim2.new(0.358, 0,0, 0) end if Objects.TextLabel1.Position == UDim2.new(0.523, 0,0.605, 0) then wait(1) Objects.TextLabel1.Position = UDim2.new(0.521, 0, 0.305, 0) end if Objects.TextLabel2.Position == UDim2.new(0.523, 0,0.604, 0) then wait(1) Objects.TextLabel2.Position = UDim2.new(0.521, 0,0.304, 0) end for i,v in pairs(Objects) do if v.ClassName == 'TextButton' then if not v.Visible then v.Visible = true end end end end
Ad
Log in to vote
0
Answered by 4 years ago

As far as i can see, the only issue is that you are defining a GuiObject.Position as two arrays, not a UDim2 value (which is what it is.)

Simply replace

{0.358, 0},{0.303, 0}

with

UDim2.new(0.358,0,0.303,0)

If you want to use it, I made a neater version as an example:

local P = script.Parent
local IL = P.ImageLabel1
local TL = P.TextLabel1
local TL2 = P.TextLabel2
for n = 1,5 do
    local c = P:FindFirstChild('TextButton'..n)
    c.Visible = false
end
if IL.Position == UDim2.new(0.358,0,0.303,0) then
    wait(1)
    IL.Position = UDim2.new(0.358,0,0,0)
end
if TL.Position == UDim2.new(0.523,0,0.605,0) then
    wait(1)
    TL.Position = UDim2.new(0.521,0,0.305,0)
end
if TL2.Position == UDim2.new(0.523,0,0.604,0) then
    wait(1)
    TL2.Position = UDim2.new(0.521,0,0.304,0)
end
for s = 1,6 do
    local T = P:FindFirstChild('TextButton'..s)
    if T.Visible == false then
        T.Visible = true
    end
end
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

you need to put an end after every task so here is the edit

if script.Parent.Visible == true then
    script.Parent.TextButton1.Visible = false
    script.Parent.TextButton2.Visible = false
    script.Parent.TextButton3.Visible = false
    script.Parent.TextButton4.Visible = false
    script.Parent.TextButton5.Visible = false
end
if  script.Parent.ImageLabel1.Position == UDim2.new(0.358, 0,0.303, 0) then
    wait(1)
    script.Parent.ImageLabel1.Position = UDim2.new(0.358, 0,-0, 0)
end
if  script.Parent.TextLabel1.Position = UDim2.new(20.523, 0,0.605, 0) then
    wait(1)
    script.Parent.TextLabel1.Position = UDim2.new(20.521, 0,0.305, 0)
end
if  script.Parent.TextLabel2.Position = UDim2.new(20.523, 0,0.604, 0) then
    wait(1)
    script.Parent.TextLabel2.Position = UDim2.new(20.521, 0,0.304, 0)
end
if  script.Parent.TextButton1.Visible == false then
    wait(1)
    script.Parent.TextButton1.Visible == true
end
if  script.Parent.TextButton2.Visible == false then
    wait(1)
    script.Parent.TextButton2.Visible == true
end
if  script.Parent.TextButton3.Visible == false then
    wait(1)
    script.Parent.TextButton3.Visible == true
end
if  script.Parent.TextButton4.Visible == false then
    wait(1)
    script.Parent.TextButton4.Visible == true
end
if  script.Parent.TextButton5.Visible == false then
    wait(1)
    script.Parent.TextButton6.Visible == true
end
0
Still won't work. vincentthecat1 199 — 4y
0
i forgot that something in the script Gameplayer365247v2 1055 — 4y
0
edited version above and it should work Gameplayer365247v2 1055 — 4y

Answer this question