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

Trying to set DisplayDistanceType?

Asked by
wackem 50
9 years ago

My code is as follows, in a gui (the parent tree is correct) it is in a normal script also

local plr = script.Parent.Parent.Parent
local char = plr:WaitForChild("Character")
local hum = char.Humanoid

hum.DisplayDistanceType = "None"

I do not know why this does not work at all...

1 answer

Log in to vote
1
Answered by 9 years ago

Your problem isn't line 5 where you are setting the DisplayDistanceType, it's on line 2, you will always be waiting for Character. To properly wait for the character you can use this method:

local plr = game.Players.LocalPlayer
plr.CharacterAdded:wait()
local character = plr

Now your updated code

local plr = script.Parent.Parent.Parent
plr.CharacterAdded:wait() --this waits until the event is fired
local char = plr.Character
local hum = char.Humanoid

hum.DisplayDistanceType = "None"
Ad

Answer this question