Upgrade button script don't work

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I wanna achive my upgrade button work
  2. What is the issue? Include screenshots / videos if possible!
    Issue is - when i click button nothing happens.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tryed to add some loops and debugs, but can’t find error

script:

local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local PlayerGui = Player.PlayerGui
local Points = Player.leaderstats.Points
local MorePointsButton = script.Parent
local UpgradeCost = 2
local GameGUI = PlayerGui.GameGUI
local StatsFolder = GameGUI.GameFrame.PlayableFrame:WaitForChild("Stats")
local PointsMulti = StatsFolder.PointsMulti
local RebirthMulti = StatsFolder.RebirthMulti
MorePointsButton.MouseButton1Click:Connect(function()
	if Points == UpgradeCost then
		PointsMulti.Value = PointsMulti.Value + (1 * RebirthMulti)
	else
	return
		end

end)

This is the error, Points.

You are only referring to the Instance itself, not the value. So you should do Player.leaderstats.Points.Value.

Oh sorry, forgot just last time didn’t saved my game, so this is old progress already used value, same error

Could you show me which line points the error and the error message?

No errors, just made some prints give me a second

Or save rewriting and do

if Points.Value == UpgradeCost then

My loop is working, when player don’t have enough points it’s return. Oh i see i wrote == not >=, + when 2 == 2 it says:

1 Like

You’re attempting to perform arithmetic operations with an instance and a number. You should refer the Value property.

Uhhh??? Don’t understand, just like i need to do arithmetic thing

Oh got it bruh, i’m stupid loool

Yay it works, thanks you a lot!

Meaning, let’s say I’m comparing a number with a part. It errors because in logic, you can’t do math operations with a part. This same goes to your Points instance. You’re only referring the Points object itself, not the .Value.

Yeah got it already, thanks you a lot!

1 Like