Hey, so am currently making a clicker game where you click to get points but there is a capacity for how much points you could have so you sell your points to reset your capacity and click more, you can also upgrade your clicks but I have a bug where when your clicks give you higher points then your capacity and you click then sell instantly then you would get more money then your max capacity,I tried to fix this by adding a while true do and every 0.01 second it would check if your points are higher then your capacity if they are it would set them to your max capacity, however that does not look good visually, how do I fix this?
Can you please show me the code, then I can try to help you.
I cant use my pc currently but it goes something like this:
If mouse clicked:connect(function()
If points.value < capacity then
Points.value = points.value + click.value
End
End)
And then the code that check if the points are higher then the capacity:
While true do
Wait(0.1)
If Points.value > capacity.value then
Points.value = capacity.value
End
Then the selling:
If key (e) pressed then
Coins.value = points.value * 3
Points.value = 0
End
And then I have a code that changes your click value,some of the code is wrong like if key pressed and mouse click because I dont remember the codes for them but they do work
Is it a tool that gives you points?
Nope its just clicking the screen
Hey @bobsdestroyer so we’re on the same page, what seems to be the current issues so I can give you a detailed and helpful answer.
Please include if you plan to have it layed out as a leaderstats on the playerlist or values in the script itself only.
I will follow up with some example codes to help you out.
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local points = localPlayer.Leaderstats.Points.Value
local maxpints = 150
--The click event without any tools.
mouse.Button1Down:Connect(function()
if points <= max points then
points = points + 1 --Adds point
else
--Add code to display maxed points error, keep in mind you can have a system to change maxpoints using maths.
end
end)
--Key pressed, In this instance "e"
mouse.KeyDown:connect(function(key)
if key == "e" then
Coins.value = points.value * 3
Points.value = 0
end
end)
If theres any issues or im incorrect please ping me in your next post using @wolfiethedino and I will help you out more.
Hey,thanks for the example,I am planning on using leader stats,Ill try that example once I have access to my pc ![]()
Yup, please leave this thread open and unsolved until you are 100% sure this works and you are satisfied with the help.
I’m not too sure if what I’m about to say is your desired outcome, but if it isn’t, then just read along. When you press e to sell, I see that you set the coin value to 3 times the amount of points they have, and then set the points to 0.
So, I’m not sure if you intended this, but the most amount of coins they will ever be able to get is 3 times the max capacity(since points fill that up(or at least from what I can tell)). You might want to add the point onto the coins, such as coins = (points *3) + coins.