local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local showRollsResultEvent = ReplicatedStorage:WaitForChild("ShowRollsResult")
local effectsDisplay = script.Parent.EffectsDisplay
local currentlyDisplayed = script.Parent.CurrentlyDisplayed
local targetPosition = UDim2.new(0.5,0,0.45,0)
local rollTweenInfo = TweenInfo.new(
0.25,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In,
0,
false
)
local function showRollsResult(rollsResult)
for i, effect in ipairs(rollsResult) do
local clonedDisplay = effectsDisplay:WaitForChild(rollsResult[i]):Clone()
clonedDisplay.Parent = currentlyDisplayed
local tween = TweenService:Create(clonedDisplay, rollTweenInfo, {Position = targetPosition})
clonedDisplay.Visible = true
tween:Play()
tween.Completed:Wait()
if i ~= #rollsResult then
clonedDisplay:Destroy()
else
task.wait(2)
clonedDisplay:Destroy()
end
end
end
showRollsResultEvent.OnClientEvent:Connect(showRollsResult)
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local rollEvent = ReplicatedStorage:WaitForChild("Roll")
local showRollsResultEvent = ReplicatedStorage:WaitForChild("ShowRollsResult")
local updateInventoryEvent = ReplicatedStorage:WaitForChild("UpdateInventory")
local chances = {
--1: the #/10 = %chance
--2: the #*10/100 = %chance
--3: 10(1%)*the % you want
["Common"] = 500; -- 50% chance
["Uncommon"] = 250; -- 25% chance
["Rare"] = 125; -- 12.5% chance
["Aquatic"] = 100; -- 10% chance
["Epic"] = 75; -- 7.5% chance
["Legendary"] = 50; -- 5% chance
["Guilt"] = 25 -- 2.5% chance
}
local function roll(player)
local PlayerDataFolder = ServerStorage:WaitForChild("PlayerData"):WaitForChild(player.UserId)
local InventoryFolder = PlayerDataFolder:WaitForChild("Inventory")
local listOfResults = {}
for count = 1, 5, 1 do
local random = math.random(1,1000)
local counter = 0
for effect, weight in pairs(chances) do
counter = counter + weight
if random <= counter then
table.insert(listOfResults, effect)
break
end
end
end
showRollsResultEvent:FireAllClients(player, listOfResults)
task.wait(3.25)
if InventoryFolder:FindFirstChild(listOfResults[5]) then
InventoryFolder:WaitForChild(listOfResults[5]).Value += 1
else
local effect = Instance.new("IntValue")
effect.Name = listOfResults[5]
effect.Value = 1
effect.Parent = InventoryFolder
end
updateInventoryEvent:FireClient(player, listOfResults[5])
end
rollEvent.OnServerEvent:Connect(roll)
I figured out it was a spelling mistake in one of my “Fire” events. Instead of “FireClient” I put “FireAllClients” Thank you for your assistance anyway!