Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I change text based on an IntValue?

Asked by 7 years ago

I've tried to make this script work.

01local o = game.Players.LocalPlayer.Data.Num
02local ow = game.Players.LocalPlayer.Data.Num.Value
03 
04 
05o.Changed:Connect(function()
06if ow == 1 then
07    script.Parent.Text = 'one'
08 
09elseif ow == 2 then
10    script.Parent.Text = 'two'
11 
12elseif ow == 3 then
13    script.Parent.Text = 'three'
14end
15end)

On player entry, IntValues are copied into the player, and I don't get why this script doesn't respond to their changes.

Please help.

2 answers

Log in to vote
1
Answered by
FazNook 61
7 years ago
Edited 7 years ago

What you must be doing is

1o.Changed:connect(function(value)
2if value == 1 then print(“one”)
3elseif value == 2 then print(“two”)
4elseif value == 3 then print(“three”)
5else print(value)
6end
7end)

Also consider changing the “ sign on the above code because I’m on my phone and it’s different on pc. You don’t need to set a ‘ow’ and what you were doing wrong is that the script runs coded like by line and once it has executed a line it doesn’t come back. So local ow will always be what value it had at the time of execution. You can also do it bu placing local ow inside the changed function.

Thank you!

Ad
Log in to vote
0
Answered by
soutpansa 120
7 years ago

try this:

1wait(2)
2 
3local ow = game.Players.LocalPlayer.Data.Num
4 
5while true do
6wait()
7script.Parent.Text = ow.Value
8end
0
tell me if it doesn't work soutpansa 120 — 7y

Answer this question