I am working on a Straight Lucky Frame spin system and its not working properly. The problem is show in the video how the image are overlapping when using Instant Spin. I think the problem causing because of the values. I choose them randomly.
without Instant Spin
With Instant Spin
This is how its work
-
What is the issue? Include screenshots / videos if possible!
The images are overlapping. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
If there any other way you can suggest or you can fix the values would be great.
function Spin()
local MinimumSpin = (playerDataFolder.CanInstantSpin.Value and Gamepass.InstantSpinConfig.Enabled) and 1 or 5
if SpiningBool or playerDataFolder.SpinCount.Value <= 0 then if Gamepass.AutoSpinSpinConfig.Enabled then AutoSpin() end return end
SpiningBool = true
for _, image in pairs(ItemFrame.Frame1:GetChildren()) do -- reset the position for the spin
if image:IsA("ImageLabel") then
image.Position = ImagesPrePos[image][1]
image.Size = ImagesPrePos[image][2]
image.ImageTransparency = .5
end
end
ShowItem.Visible = false
SpinFrame.Visible = true
local ChoosenReward = ChooseRewardsRF:InvokeServer() ---get the image index
local SpinCount = 0
local SpeedFactor = 1.5
local FinalSpinCount = {}
local Acceleration = 0.21
local MinSpeedFactor = (playerDataFolder.CanInstantSpin.Value and Gamepass.InstantSpinConfig.Enabled) and 1 or 1.5
local lastTime = tick()
local function SpinItems()
local currentTime = tick()
local deltaTime = currentTime - lastTime
lastTime = currentTime
local moveDistance = SpeedFactor * deltaTime
for i, image in ipairs(ItemFrame.Frame1:GetChildren()) do
if image:IsA("ImageLabel") then
local newX = image.Position.X.Scale - moveDistance ---next position calculation
image.Position = UDim2.fromScale(newX, image.Position.Y.Scale) --assiging the position
if image.Position.X.Scale < -0.095 then --if image crassed this distance then send it in the end
image.Position = UDim2.fromScale(1.601,image.Position.Y.Scale)
end
if SpinCount > MinimumSpin and image.LayoutOrder == ChoosenReward then
-- if conditions satisfied then give the reward this have nothing related to the spin movement
if Gamepass.AutoSpinSpinConfig.Enabled and playerDataFolder.CanAutoSpin.Value then
Spin() -- call the entire function again as long as auto spin
end
end
end
end
if SpeedFactor > MinSpeedFactor then --speedfactor changes after each
SpeedFactor = math.max(MinSpeedFactor, SpeedFactor - Acceleration * deltaTime)
end
end
RS:BindToRenderStep("SpinFrames",Enum.RenderPriority.Camera.Value,SpinItems)
end
Button.Clicked:Connect(Spin)
Also i tried to use a frame and put the images in it and clone it and move the frames once one of the frame crossed the end point it places back in the end.
But the problem with this was both frames were moving with different speed the image in the back was moving faster