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

How can I get the name of a service and use it like a variabe?

I don't want to do game.StarterPlayer because I have a script that changes the name of it every second, so I want to get the name of the StarterPlayer service ans use it in a variable.

This is my code that isn't working:

local lol = game:GetService("StarterPlayer"):GetFullName()

wait()
lol.CameraMaxZoomDistance = 1

1 comment

0

:GetFullName() returns a string -- just do local lol = game:GetService("StarterPlayer") and it should work

1 answer

✓ Accepted answer

As described in the comment by fredfishy, you'll want to use local lol = game:GetService("StarterPlayer")

Doing so will create a variable lol that points to StarterPlayer.

By doing the :GetFullName() method, you're creating a variable of the text "game.StarterPlayer" which shouldn't help you in what you want to accomplish.

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