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

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

Asked by 6 years ago

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
0
`:GetFullName()` returns a string -- just do `local lol = game:GetService("StarterPlayer")` and it should work fredfishy 833 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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.

Ad

Answer this question