Hello everyone,
I am making a script currently here is my code :
script.Parent.Confirm_Button.MouseButton1Click:Connect(function()
local StringName = tostring(script.Parent.Username_Change.Text)
end)
So, I was wanting too do something like :
game.workspace.StringName.Head
etc
But it won’t let me do that and I don’t know any other way of doing this any advice or help ?
Emskipo
(Emskipo)
2
If the script is a local script. Then just get the character from the player.
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
Then do:
local StringName = script.Parent.Username_Change.Text
char.Humanoid.DisplayName = StringName
Kaid3n22
(Kaiden)
3
you could use 1 of 2 ways, get the player directly and get the character from there
game.Players[StringName].Character.Head
or just get the character.
workspace[StringName].Head
To try and get a child using a variable, you need to use brackets.
1 Like
Thank you for that quick reply, this worked well thank you.