I want to make a system where players open the shop, pick a crate, and then the crate randomly picks a skin.
How would I do this?
I was thinking maybe a table of skins, but how would the script pick randomly?
I want to make a system where players open the shop, pick a crate, and then the crate randomly picks a skin.
How would I do this?
I was thinking maybe a table of skins, but how would the script pick randomly?
this module might be able to help you.
EXAMPLE OF USAGE:
local rt = require(script.ServerScriptService.LuckManager)
--assign weights to any string that you want.
--(in this case we'll use common,uncommon,rare etc)
--these DO NOT need to add up to 100, just think of it as a jelly bean jar.
local weights = {Common = 100, Uncommon = 50, Rare = 5, Epic = 3, Legendary = 1}
--Roll the weights table and see what you get!
local tag = rt:Roll(weights)
--verify what tag was rolled and give a player an item.
if(tag == "Common") then
print("You landed on a common tag!")
--give player a random common item here
end
One question, Where should I put this script? Workspace, ScriptService, or In the GUI it self
any where that its needed, but I recommend placing it into ServerScriptService so players can’t exploit the odds of your case loot.
you don’t have to change anything in the module script.
you just have to require it into another script that handles your cases
Ok the second problem I’m having is this
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local i = Instance.new("Folder")
i.Name = "leaderstats"
i.Parent = player
local v = Instance.new("IntValue")
v.Name = "Cash"
v.Parent = i
local data1
local success, errormessage = pcall(function()
data1 = myDataStore:GetAsync(player.UserId.."-Cash")
end)
if success then
v.Value = data1
print("Successfuly saved data")
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-Cash",player.leaderstats.Followers.Value)
end)
if success then
print("Player data successfully saved!")
else
print("There was an error when saving data")
warn(errormessage)
end
end)
--Datastore script
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
if player.leaderstats.Cash >= 0 then
script.Parent.Visible = false
script.Parent.Parent.NormalCratePrice.Visible = false
script.Parent.Parent.SkinGiver.Visible = true
script.Parent.Parent.SkinName.Visible = true
end
end)
end)
--Text Button Script
I’m getting an error saying Players.TSF_Lacker.PlayerGui.ScreenGui.Frame.NormalCrate.Script:4: attempt to index nil with ‘leaderstats’
Cough cough
A neat little system was already made for this.
I know i shouldnt ask for a whole script, Im a bit confused
But can you give me a photo of the explorer
does this work properly anymore cause i am unable to get a result the roll function is not there
Hello, can u make an example for :Roll() please im sending a table of pets and getting the error of “There is no entries to roll for”