top of page

How To Use The Changed Method

What is Changed?

“Changed” refers to a method, or built in function that is a part of Roblox Studio. It can be thought of as a listener. Its job is to listen for changes to the value that it has been attached to, then do something when that value changes.

What is a Value?

The code below when placed in a Script in the ServerScriptService will do the following.

  • Create a leaderboard for each player

  • Create a Gold value for each player and place it on the leaderboard.

  • Increase the Gold value every 2 seconds.

The important thing to take note of is the plrGold.Value. This is an example of something that then Changed method can be used to listen to.

		local leaderstats ="Folder",player)
		leaderstats.Name = "leaderstats"
		local plrGold ="NumberValue",leaderstats)
		plrGold.Name = "Gold"
		plrGold.Value = 0
			while task.wait(2) do
				plrGold.Value += 10

How To Use Changed

To see the changes to the plrGold value above we can create a Local Script and place it in the StarterCharacterScripts folder as an example.

In the local script add the following code.

local Players = game:GetService("Players")
local player = Players.LocalPlayer

	print("Gold Changed")

As you can see we are accessing the players Gold Value and attaching the Changed method to it. We then connect a function that will show the print message in the output window.

You can use the Changed method on any object that has a VALUE attached to it. Just remember that you use Changed on the name of the value not the value itself.

8 views0 comments

Recent Posts

See All


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page