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

How to make TextLabel change from client?

Asked by 4 years ago

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.

0
You cannot implicity convert an integer to an String, please use tostring(speed) cailir 284 — 4y

2 answers

Log in to vote
1
Answered by
U_srname 152
4 years ago
Edited 4 years ago

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!

0
Revision, literally should only be listening to WalkSpeed instead of a global .Change fires event. SmartNode 383 — 4y
1
Thanks for the help. User#29320 0 — 4y
Ad
Log in to vote
1
Answered by
SmartNode 383 Moderation Voter
4 years ago

Use this:

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

0
Thanks for the help. User#29320 0 — 4y

Answer this question