Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How i can make my DoublePass working with Pets multiplier?

Hi! I did a Pet system with multipliers but i have a problem If want it to multiply with my DoublePass i dont get the results i wanned If i dont have any pet equipped i get 2 points, if i equip the Cow pet i get 3 if i have a Burger i get also 3 if i have Angel i get 3 and same at every pet Here is the script:

script.AddPoints.OnServerEvent:connect(function(plr)
	plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +plr.leaderstats.Prestige.Value + 1
	if plr.DoublePass.Value == 2 then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +plr.leaderstats.Prestige.Value *2
	end
	if plr.EquippedPet.Value == "Cow" then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1 +plr.leaderstats.Prestige.Value *2 *plr.DoublePass.Value
	end
	if plr.EquippedPet.Value == "Burger" then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1 +plr.leaderstats.Prestige.Value *3 *plr.DoublePass.Value
	end
	if plr.EquippedPet.Value == "Angel" then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1 +plr.leaderstats.Prestige.Value *4 *plr.DoublePass.Value
	end
	if plr.EquippedPet.Value == "Demon" then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1 +plr.leaderstats.Prestige.Value *5 *plr.DoublePass.Value
	end
	if plr.EquippedPet.Value == "Aqua Dragon" then
		plr.leaderstats.Points.Value = plr.leaderstats.Points.Value +1 +plr.leaderstats.Prestige.Value *6 *plr.DoublePass.Value
	end
end)

how can i fix it? Thank you!

1 answer

✓ Accepted answer
script.AddPoints.OnServerEvent:connect(function(plr)
	local amountAdded = 1 -- default amount (will always give at least 1?)

	-- first you want to add the pet values before multiplying with the gamepass if you want double to work with the pets

	if plr.EquippedPet.Value ~= '' then
		if plr.EquippedPet.Value == PET_NAME then -- write out for each pet or make a module with all pet info and do if module[pet_name] then amountAdded *= module[pet_name].multiplier
			amountAdded *= AMOUNT_THE_PET_GIVES -- can also change to add or whatevery you want
		end
	end

	-- now multiply the amountAdded with double gamepass

	if game:GetService('MarketplaceService'):UserOwnsGamePassAsync(plr.UserId, GAMEPASS_ID) then
		amountAdded *= 2
	end

	-- now add the amount to your player
	plr.leaderstats['STAT_WANTED'].Value += amountAdded
end)

1 comment

0

Thank you! And btw you forgot about rebirth multiplier but its easy. At local amountAdded = 1 write this: local amountAdded = 1 * (plr.leaderboards.Prestige.Value + 1)

This discussion is preserved as it was. New answers, comments, and votes are closed.