You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
…
What is the issue? Include screenshots / videos if possible!
ive posted other posts like this, its a coin event script i fixed the main issue by myself but the other issue is, when i make the event, it multiplies your coins by 4x (even if its above 4x) and i would like to do 10x coins.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i looked for solutions everywhere, even on the Devforum and found nothing
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
heres the script im using for it:
game.Players.PlayerAdded:Connect(function(player)
local marketservice = game:GetService("MarketplaceService")
local can = true
local leader = player:WaitForChild("leaderstats")
if leader then
repeat wait() until leader:FindFirstChild(script:WaitForChild("Currency").Value)
local currency = leader:FindFirstChild(script:WaitForChild("Currency").Value)
if currency then
local folder = Instance.new("Folder",player)
folder.Name = "CoinEvent"
local oldmoney = Instance.new("IntValue",folder)
oldmoney.Name = "OldMoney"
oldmoney.Value = currency.Value
local give10x = Instance.new("IntValue",folder)
give10x.Name = "Give10x"
give10x.Value = 0
local give12x = Instance.new("IntValue",folder)
give12x.Name = "Give12x"
give12x.Value = 0
currency.Changed:Connect(function()
if can == true then
can = false
if currency.Value > oldmoney.Value then
give10x.Value = currency.Value - oldmoney.Value
currency.Value = currency.Value + give10x.Value
oldmoney.Value = currency.Value
can = true
else
if marketservice:UserOwnsGamePassAsync(player.UserId, script:WaitForChild("GamepassId").Value) then
oldmoney.Value = currency.Value + give12x.Value
end
end
end
end)
end
end
end)
yes im aware im using a gamepass script for a coin event…i couldnt find anything else.
i dont know why it doesn’t let me go past 4x coins. can someone please help me fix this weird issue?
Thank You!
I need a lot more to go on. Where is 4x even located? What do you mean specifically that it won’t go past it? If this is a math error, print the values or use the debugger and tell me what variables are what. If this is a flow error, add prints or use the debugger to see where the code goes.
Sorry, I was busy. I don’t fully understand this. It’s kinda hard to see what you’re doing, but I’ll go through it line by line.
Let me tell you what I see, correct me if I’m wrong. We can go from there.
It detects players added and runs for each new player.
It waits for leaderstats to exist which must be created in another script.
It waits for Currency.Value in leaderstats. I don’t know what this is or what script it is created in, but you make it seem like that isn’t the issue so it probably doesn’t matter.
It creates a new hierarchy of data in player.
It sets Give10x.Value to 0, I want to know what this is supposed to do and why it is 0, same with Give12x.Value
Here’s where it looks like the problems start. can is a variable that prevents this code from running twice it looks like? The problem with it is that it only is set to true again when it runs the give10x section, not the give12x.
After that, I assume you want to run either 10x or 12x, not both. Currently, it will only run 10x unless money is being subtracted. That’s an easy fix.
The math here is confusing, but I assume you want to detect how much money was added and multiply that by 10 or 12 depending on the game pass? If so, that math needs to be re-done.
Let me know if this is correct, I will be back after a trip to Home Depot if this hasn’t been resolved. You won’t need to bump this thread.
the lua Currency.Value is for something in the script, which would be coins. im also having a little bit of trouble understanding, but i think you might be right.
So what you will need to do is, as soon as the currency is changed, check if the currency went up. If the currency went up, you need to check if they own the gamepass. If they do, subtract the amount the earned, multiply it by 12, and then add it back to Currency. If not, do the same but multiply it by 10.