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

Issue with autogeneration script?

Asked by
WVPII 5
8 years ago

This script generates this:

As you can see, they are overlapping. How why is this?

It prints this, btw: 0 line 0 positionOnLine 0 line 1 positionOnLine 0 line 2 positionOnLine 1 line 3 positionOnLine 1 line 0 positionOnLine 1 line 1 positionOnLine 1 line 2 positionOnLine

--[[Scripted by WolfgangVonPrinz]]--
local frame = script.Parent
local genericFrame = script.templateFrame
local data = workspace.Data.MeshData

function findPosition(i)
    local positionOnLine = i % 4== 0 and 3 or (i % 4) - 1   
    local line = math.floor(i / 4)
    print(line .. " line")
    print(positionOnLine .. " positionOnLine")
    return UDim2.new(0, 5 + (positionOnLine * 115), 0, 5 + (line * 120) and positionOnLine ~= 3 or ((line - 1) * 120) + 5)
end

for i,v in pairs(data:GetChildren())do
    local position = findPosition(i)
    local Image = genericFrame:Clone()
    Image.Parent = frame
    Image.Position = position
    Image.PointPrice.Value = v.Price.Value
    Image.Image = "rbxassetid://" .. tostring(v.DecalId)
end

Answer this question