This is for the gambling thingy.I want to make it like this:“Player” got 50 EXP with the chance of 50% from gambling!
local GambleHere = script.Parent
local clickDetector = GambleHere:FindFirstChild("ClickDetector")
local rewards = {
{ name = "Gold", amount = 250000000000, chance = 0.1 },
{ name = "Gold", amount = 50, chance = 50},
{ name = "Kromer", amount = 1, chance = 5 },
{ name = "Kromer", amount = 10, chance = 1 },
{ name = "XP", amount = 100, chance = 10 },
{ name = "XP", amount = 10000, chance = 1 },
{ name = "Weapon", weaponName = "Stick", requiredStats = { LOVE = 1, Resets = 0, TrueResets = 0 }, chance = 19.5 },
{ name = "Weapon", weaponName = "Stick", requiredStats = { LOVE = 1, Resets = 0, TrueResets = 0 }, chance = 0.5 },
}
local function drawMessage(player, message)
-- here
end
local function giveReward(player, reward)
if reward.name == "Gold" then
player.Gold.Value = player.Gold.Value + reward.amount
drawMessage(player, "You have obtained " .. reward.amount .. " Gold!")
elseif reward.name == "Kromer" then
player.Kromer.Value = player.Kromer.Value + reward.amount
drawMessage(player, "You have obtained " .. reward.amount .. " Kromer!")
elseif reward.name == "XP" then
player.XP.Value = player.XP.Value + reward.amount
drawMessage(player, "You have obtained " .. reward.amount .. " EXP!")
elseif reward.name == "Weapon" or reward.name == "AsgoreTrident" then
local weaponName = reward.weaponName
if player.Weapons:FindFirstChild(weaponName) and
player.LOVE.Value >= reward.requiredStats.LOVE and
player.Resets.Value >= reward.requiredStats.Resets and
player.TrueResets.Value >= reward.requiredStats.TrueResets then
if player.Weapons[weaponName].Value == false then
player.Weapons[weaponName].Value = true
drawMessage(player, "You have obtained the " .. weaponName .. "!")
else
drawMessage(player, "You already own this weapon!")
end
else
drawMessage(player, "You don't meet the requirements for this weapon.")
end
end
end
local function trickOrTreat(player)
local totalChance = 0
local randomNum = math.random(100)
for _, reward in ipairs(rewards) do
totalChance = totalChance + (reward.chance or 0)
end
for _, reward in ipairs(rewards) do
if randomNum <= reward.chance / totalChance * 100 then
giveReward(player, reward)
break
else
randomNum = randomNum - (reward.chance or 0)
end
end
end
if clickDetector then
clickDetector.MouseClick:Connect(function(player)
trickOrTreat(player)
end)
else
warn("ClickDetector not found!")
end
local respawnDelay = 60
while true do
clickDetector.MaxActivationDistance = 0
wait(respawnDelay)
clickDetector.MaxActivationDistance = 32
end