Why Is My Skip Button Script Broken?

Here Is The Script:
skip = script.Parent
text1 = skip.Parent.text1

line1 = skip.Line1
line2 = skip.Line2
line3 = skip.Line3

skip.MouseButton1Click:Connect(function()
text1.Text = tostring(line1)
end)

skip.MouseButton1Click:Connect(function()
text1.Text = tostring(line2)
end)

skip.MouseButton1Click:Connect(function()
text1.Text = tostring(line3)
end)

The issue is when i touch the skip button 1st it will say “Line1” And not the text of the Line1
And Line1, Line2, Line3 are stringValues

And the rest doesn’t work

1 Like

Can you screenshot how this looks with the parents and the children, and also screenshot what exactly happens while testing?

okay wait please
i’ll record them

1 Like

If you are trying to set the text to display the value of a StringValue, you should be using tostring(line1.Value), instead of tostring(line1), because currently you are turning the instance (not the value) into a string.
Also there’s no need for the tostring() part. A value inside a stringvalue is already a string.

And also a little tip for inserting code into a post:
Put three backticks on each end of the code (```) to turn it into a formatted lua box like this:

print("Hello, world!")
1 Like

here a vid and screenshot:


Capture

1 Like

fixed that but when i press the button the first time it shows line1’s value and i skip 2nd time nothing happpens

1 Like

Are you getting any errors in the output (View image > Output image)?
And make sure you change all the tostring(line1,line2,line3…) to tostring(line1.Value,line2.Value…)

the output is as empty as my brain

1 Like

Oh i see now, the skip button (when clicked) is firing all 3 events changing the text at the same time.
Try something like:

skip = script.Parent
text1 = skip.Parent.text1

line1 = skip.Line1
line2 = skip.Line2
line3 = skip.Line3

line = 0

skip.MouseButton1Click:Connect(function()
   line += 1 -- Increases the line variable by 1
   if line == 1 then -- If its the first line
      text1.Text = tostring(line1.Value) -- Set text to line1
   end
   if line == 2 then -- If its the second line
      text1.Text = tostring(line2.Value) -- Set text to line2
   end
   if line == 3 then -- If its the third line
      text1.Text = tostring(line3.Value) -- Set text to line3
   end
   --[[ add more if needed, or end it by changing the parent frame's "Visible" 
    property to false on line == 4 ]]
end)


Could be wrong but give it a try

1 Like

thank you ur right :slight_smile:

No problem :slight_smile:
Glad I could help

1 Like

This is correct, just make sure to use else if’s for better formatting and stuff.

1 Like

Yeah forgot about that.
If you wanted to get real messy though you could use a ton of conditional statements (but thats just confusing)

skip.MouseButton1Click:Connect(function()
   line += 1 -- Increases the line variable by 1
   text1.Text = (line == 1 and line1.Value or (line == 2 and line2.Value or (line == 3 and line3.Value or "")))
end)

Anyway here’s the elseif code if needed:

skip.MouseButton1Click:Connect(function()
   line += 1 -- Increases the line variable by 1
   if line == 1 then -- If its the first line
      text1.Text = tostring(line1.Value) -- Set text to line1
   elseif line == 2 then -- If its the second line
      text1.Text = tostring(line2.Value) -- Set text to line2
   elseif line == 3 then -- If its the third line
      text1.Text = tostring(line3.Value) -- Set text to line3
   end
   --[[ add more if needed, or end it by changing the parent frame's "Visible" 
    property to false on line == 4 ]]
end)

2 Likes

thank you but the other one i already used

but idk how to make a typewrite fx for it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.