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

Why doesnt this script print the positions of the txt buttons?

Asked by 5 years ago
local StartingQuestion = script.Parent.Parent.Parent.EXQUESTION1
local Button = script.Parent
local PosAnswer1 = StartingQuestion.One
local PosAnswer2 = StartingQuestion.Two
local PosAnswer3 = StartingQuestion.Three
local PosAnswer4 = StartingQuestion.Four
local pos1 = PosAnswer1.Position
local pos2 = PosAnswer2.Position
local pos3 = PosAnswer3.Position
local pos4 = PosAnswer4.Position
Button.MouseButton1Click:Connect(function()
 local position = math.random(1,4)
 if position == 1 then
 print(pos1 .. " Pos1")
 end
 if position == 2 then
  print(pos2 .. " Pos2")
 end
 if position == 3 then
 print(pos3 .. " Pos3")
 end
 if position == 4 then
  print(pos4 .. " Pos4")
 end
end)

Im trying to eventually tween the postions to random positions for macro protection! It is not printing the positons of the PosAnswers!

1
on lines 14, 17, 20 and 23 you tried to concat userdata and strings, it shouldve thrown an error. you need to call tostring() on it before concatenating GoldAngelInDisguise 297 — 5y
0
or you can just replace the `..` with a `,` and pass multi args EpicMetatableMoment 1444 — 5y

1 answer

Log in to vote
0
Answered by
metryy 306 Moderation Voter
5 years ago

You need to use the tostring( var ) to convert the position value to a string so you can concatenate it in the print function.

Example:

print("Position 1: " .. tostring(pos1))
Ad

Answer this question