I want my dialog to say the name of localplayer but I don't know how

Am i doing wrong?

function setText(word)
    Text = word
    for i = 1, #Text do
        TextLabel.Text = string.sub(Text, 1, i)
        SoundEffect() 
        TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
        wait(0.04)
    end
end


wait(2)
setText("Message.")
wait(3)
setText("Hello!..game.Players.LocalPlayer.Name.."!")

Should be

setText("Hello!" .. game:GetService("Players").LocalPlayer.Name .. "!")
1 Like

it prints this error

The script must be a localscript, you can’t get the LocalPlayer from the server, it’ll always return nil

1 Like

Oh its true. Thanks for your feedback! :upside_down_face:

1 Like