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

How to make TextLabel change from client?

Code:

local player = game.Players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local speed = hum.WalkSpeed
if speed.Changed then
	script.Parent.Text = speed
end

Error I get :

  16:10:52.808 - Players.Krosloe.PlayerGui.ScreenGui.TextLabel.LocalScript:5: attempt to index local 'speed' (a number value)

What would I change for the textlabel to change everytime the client walkspeed changes. Thanks.

1 comment

0

You cannot implicity convert an integer to an String, please use tostring(speed)

2 answers

✓ Accepted answer

The issue you have is that the speed is a number value. There are also an event you are using incorrectly. Here's a quick fix:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

hum:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
	script.Parent.Text = tostring(speed)
end)

Hope I helped!

2 comments

0

Revision, literally should only be listening to WalkSpeed instead of a global .Change fires event.

1

Thanks for the help.

Use this:

humanoid:GetPropertyChangedSignal(‘WalkSpeed’):Connect(callback)

1 comment

0

Thanks for the help.

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