I can't update a value over and over

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

  1. What do you want to achieve?

I want to be able to update the value (string) according to the position. (simple example : think of a global leaderboard and its update mechanic it should always update in 10 mins)

  1. What is the issue?

It doesn’t update after it gets set once.

  1. What solutions have you tried so far?

I have tried to loop and look up on updating the values in DevForum.

It’s an oversimplified and small script to connect to another script.


local button = script.Parent.C
local BPosition = button.Position 



while true do
	wait(0.1)
	print("Ok Works (ValueS)")
	game.ReplicatedStorage.PositionValue.Value = button.Position.X.Scale
end

If you can help me it would be great.

Thanks!

Note : No errors in the output.
Notice : I won’t reply to much of the thread because of the discussion it sparked instead I’ll mark the solution but I’ll try the solutions you guys replied with.

any errors in the output? (personally I doubt there would be) that looks good but it could easily be broken if there is an error in the output.

Yes I’ve checked the output multiple times. No errors.

Does it print(“Ok Works”)?
If it does try and put another print statement after

to see if that line runs, it should run multiple times(print statement).

Yes it works and goes trough every mili-second.

How are you checking the value to see if it changes? Are you checking it in the Explorer menu? Or are you checking it on a TextLabel? Is this a LocalScript or a Server Script?

You should put a while loop in the text label where you check it:

while wait(0.01) do
script.Parent.Text = game.ReplicatedStorage.PositionValue.Value
end

EDIT:
This will keep checking every 0.01 seconds and updates it if the value changed.

Explorer menu and trough properties. And a normal server script.

1 Like

Just a side note, but this isn’t really good practice

There’s a Event for these specific Instances which will keep detecting the change whenever you want it to, it’s more efficient than having to do a while wait() do loop (Which isn’t that accurate, especially if you do it by a low number)

Where is this script exactly located specifically?

In player GUIs and if you are wondering the value should be in ReplicatedStorage.

I think that could explain it

Whenever you try & edit UI on the Server, it will not replicate to the client as you are using a Server Script, so in reality it would actually be changing from the Server’s standpoint and not a LocalScript (From your standpoint)

Try changing it to a LocalScript, and replace your code with this:

local button = script.Parent.C
local BPosition = button.Position 
print("This should work, but just to double check we'll go ahead and print this")

local function ChangeValue()
    print("This function has fired")
    game.ReplicatedStorage.PositionValue.Value = button.Position.X.Scale
end

button.Position.X:GetPropertyChangedSignal("Scale"):Connect(ChangeValue)
ChangeValue()
1 Like