I have a problem, basically I am making a rolling concept but when I use 'Skip' Button, the normal run which is 15 seconds will get collided in to next run, only starts happening when used skip function.
local Rarity = require(game.ReplicatedStorage.GameModules.Rarity)
local SkipButton = script.Parent.RollFrame.SkipButton
local _RandomSeed = nil
local _ItemSize = nil
local _Amount = 1
local _Timing = 15
local _Type = nil
local Chosen = nil
local ChosenFrame = nil
local Access = true
local Available = true
script.Event.Event:connect(function(Type,Amount,Timing)
local Ready = false
local Count = (script.Parent.RollFrame.ItemsFrame.Items.AbsoluteSize.X/script.Parent.RollFrame.ItemsFrame.Items.AbsoluteSize.Y)+4
local Items = {}
script.Parent.RollFrame.ItemsFrame.Items:ClearAllChildren()
_Timing = Timing
_Amount = Amount
_Type = Type
script.Parent.RollFrame.Visible = true
script.Parent.RewardFrame.Visible = false
script.Parent.RollFrame.SkipButton.Visible = true
script.Parent.RollFrame.Amount.Text = "x"..Amount
script.Parent.RollFrame.ItemsFrame.Items.Position = UDim2.new(0,0,0,0)
print(Count)
local Tick = tick()
math.randomseed(Tick)
if string.lower(Type) == "common" then
Items = Rarity.GetRarity(80,20)
Ready = true
elseif string.lower(Type) == "uncommon" then
Items = Rarity.GetRarity(20,80)
Ready = true
end
if Ready == true then
for i = 0, Count do
local Item = Items[math.random(#Items)]
local Frame = script.Template:Clone()
Frame.Background.Number.Text = i
Frame.Parent = script.Parent.RollFrame.ItemsFrame.Items
Frame.Name = tostring(Item)
Frame.Image.Color.ImageColor3 = Rarity.GetRarityColor(game.ReplicatedStorage.Items[Item].Price.Value)
Frame.Image.Image = "http://www.roblox.com/Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&aid="..Item
Frame.Size = UDim2.new(0,Frame.AbsoluteSize.Y,1,0)
Frame.Position = UDim2.new(0,Frame.AbsoluteSize.Y*i,0,0)
if i == 109 then
_Amount = _Amount - 1
Chosen = Item
ChosenFrame = Frame
end
end
end
local RandomSeed = math.random()*script.Parent.RollFrame.ItemsFrame.Items.AbsoluteSize.Y/2
_RandomSeed = RandomSeed
_ItemSize = -script.Parent.RollFrame.ItemsFrame.Items.AbsoluteSize.X
Actions(Timing)
end)
function Actions(Timing)
script.Parent.RollFrame.ItemsFrame.Items:TweenPosition(UDim2.new(0, _ItemSize + 1000 + _RandomSeed, 0, 0), "Out", "Quart", Timing,true)
if Access == true then
wait(Timing/2)
script.Parent.RollFrame.SkipButton.Visible = false
if Available == true then
wait(Timing/2)
ChosenFrame.Background.ImageColor3 = Color3.fromRGB(255, 255, 255)
wait(1)
AwardRun(game.ReplicatedStorage.Items[Chosen].Name)
print("Normal")
end
else
script.Parent.RollFrame.SkipButton.Visible = false
script.Parent.RollFrame.ItemsFrame.Items:TweenPosition(UDim2.new(0, _ItemSize + 1005 + _RandomSeed, 0, 0), "Out", "Quart", 0.5,true)
wait(0.8)
ChosenFrame.Background.ImageColor3 = Color3.fromRGB(255, 255, 255)
wait(1)
AwardRun(game.ReplicatedStorage.Items[Chosen].Name)
print("Skip")
end
end
function AwardRun(Item)
local ItemColor = Rarity.GetRarityColor(game.ReplicatedStorage.Items[Item].Price.Value)
local RollFrame = script.Parent.RollFrame
local RewardFrame = script.Parent.RewardFrame
RollFrame.Visible = false
RewardFrame.Visible = true
RewardFrame.Image.Image = "http://www.roblox.com/Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&aid="..Item
RewardFrame.Color.ImageColor3 = ItemColor
RewardFrame.Type.TextColor3 = ItemColor
RewardFrame.EquipButton.ImageColor3 = ItemColor
RewardFrame.SellButton.ImageColor3 = ItemColor
RewardFrame.CloseButton.ImageColor3 = ItemColor
RewardFrame.Type.Text = Rarity.GetTypeByID(Item)
RewardFrame.ItemName.Text = game.ReplicatedStorage.Items[Item].ItemName.Value
end
script.Parent.RewardFrame.CloseButton.MouseButton1Click:connect(function()
Access = true
Available = true
script.Event:Fire(_Type,_Amount,15)
end)
SkipButton.MouseButton1Click:connect(function()
Access = false
Available = false
Actions(_Timing)
end)
In this clip on the third time you can see when it loops it http://gfycat.com/gifs/detail/MammothNegativeFantail
