Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I change text based on an IntValue?

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

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!

try this:

wait(2)

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

while true do
wait()
script.Parent.Text = ow.Value
end

1 comment

0

tell me if it doesn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.