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 6 years ago

I've tried to make this script work.

local o = game.Players.LocalPlayer.Data.Num
local ow = game.Players.LocalPlayer.Data.Num.Value


o.Changed:Connect(function()
if ow == 1 then 
    script.Parent.Text = 'one'

elseif ow == 2 then
    script.Parent.Text = 'two'

elseif ow == 3 then 
    script.Parent.Text = 'three'
end
end)

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
6 years ago
Edited 6 years ago

What you must be doing is

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

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
6 years ago

try this:

wait(2)

local ow = game.Players.LocalPlayer.Data.Num

while true do
wait()
script.Parent.Text = ow.Value
end
0
tell me if it doesn't work soutpansa 120 — 6y

Answer this question