#UDim2 in table trouble

26 messages · Page 1 of 1 (latest)

drowsy hatch
#

I have some UDim2's in a table, but I noticed that they have commas in them so I had to make them into real UDim2's. But whenevre I tried using them it always returned {0,0},{0,0} instead of the actual value put in them. So I made them into strings but I dont know how to now convert the string into UDim2. I've tried UDim2.new(nextPoint) but that didn't work.

No errors or warnings, local script. Thanks if you can help.

local dash1 = script.Parent.Dash1
local dash2 = script.Parent.Dash2

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.25,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)

local points = {
    "{0.021, 0},{0.06, 0}",
    "{0.021, 0},{0.116, 0}",
    "{0.137, 0},{0.116, 0}",
    "{0.137, 0},{0.06, 0}"
}

local dash1Point = 1
local dash2Point = 3

local function moveDash1 ()
    local nextPointI = dash1Point + 1
    if nextPointI == 4 then
        nextPointI = 1
    end
    local nextPoint = points[nextPointI]
    print(UDim2.new(nextPoint))
    local tween = tweenService:Create(dash1,tweenInfo,{Position = UDim2.new(nextPoint)})
    tween:Play()
end
moveDash1()
#

dash1 and dash2 are both image buttons, those are the instances getting tweened.
please ping me if you have an answer/question regarding the post. once again, thanks for helping out

unique gate
#

Just use actual UDim2s

#
local points = {
    UDim2.fromScale(0.021, 0.06),
    UDim2.fromScale(0.021, 0.116),
    UDim2.fromScale(0.137, 0.116),
    UDim2.fromScale(0.137, 0.06)
}
#

You can't just feed a string to a function that takes 4 number arguments and expect it to work

vocal zealot
#

i need help with my scripting

unique gate
drowsy hatch
unique gate
#

Wdym?

unique gate
#

points[1] ~= UDim2.new(points[1])

drowsy hatch
unique gate
#

Np

#

If I might ask, what is the point of these lines:

local nextPointI = dash1Point + 1
if nextPointI == 4 then
    nextPointI = 1
end

They don't seem to be doing anything because dash1Point is never changed?

drowsy hatch
unique gate
#

Use modulus

#

5 % 4 = 1

drowsy hatch
#

Yk I havent thought of that tbh

unique gate
#

Modulus is used heavily everywhere in programming because of how useful it is

#

Really good for cycling through a set of numbers

drowsy hatch
#

Alr

#

well thanks for all that stuf

#

Ill be closing this so uh

#

cya

unique gate