When I run my code this error shows up: TweenService:Create property named ‘Position’ cannot be tweened due to type mismatch (property is a ‘UDim2’, but given type is ‘double’)
I don’t really know what it means.
My script has two problems first one is that every thing newTemplate is the same and the second one is the error wich I marked in the script.
When getting a random character from the module you will get 2 values the first one is the character name and the second one is the chance percentage:
local tweenService = game:GetService("TweenService")
local sendAnimation = game.ReplicatedStorage.RemoteEvents.SendAnimation
local characterModule = require(game.ReplicatedStorage.CharacterModule)
local template = script.Template
local player = game.Players.LocalPlayer
local itemContainer = script.Parent.ItemContainer
local spinTime = 5
sendAnimation.OnClientEvent:Connect(function(character, chance)
local numberOfItems = math.random(50,100)
local chosenPosition = numberOfItems - math.random(5, 10)
for i = 1, numberOfItems do
local newItem = i == chosenPosition and character or
characterModule.chooseRandomCharacter(player.Values.Luck.Value)
local newItemFrame = template:Clone()
print(character)
newItemFrame.Title.Text = character
newItemFrame.Chance.Text = chance.."%"
newItemFrame.Parent = itemContainer
end
local cellSize = template.Size.X.Scale
local padding = itemContainer.UIListLayout.Padding.Scale
local nextOffset = -cellSize - padding
local finalPosition = (0.5 - cellSize / 2) + (chosenPosition - 1) * nextOffset
local spinTweenInfo = TweenInfo.new(spinTime, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
print(finalPosition, itemContainer.Position)
local tween = tweenService:Create(itemContainer, spinTweenInfo, {Position = finalPosition})
tween:Play()
for _, item in pairs(itemContainer:GetChildren()) do
if item and not item:IsA("UIListLayout") and not item:IsA("UIPadding") then
item:Destroy()
end
end
end)
I got this script from someone elses code, he said he had the same problem but looked at the video and fixed it himself. He never told how. So can someone help me?