function whenClicked()
local wait = workspace:WaitForChild("Player")
local playerpos = game.Workspace.Player.Torso.Position
local leftlightpos = game.Workspace.FlashLight1.Union.Position
local difference = playerpos - leftlightpos
local number = 50
if difference.magnitude < number then
local xyzb = game.Workspace.FlashLight1.Union.PointLight
xyzb.Range = 45
end
end
script.Parent.MouseButton1Down:connect(whenClicked)
Basically, the problem I have here is that this script only works in Roblox Studio because a child called "Player" loads in to the game on test mode. However, online "Player" would be registered as the name of the user playing the game, for example if Shedletsky joined my game, "Player" = "Shedletsky". The real problem is that I do not know how to register every single player within this code, except from one person. This theory is correct, because I changed "Player" to "EmperorTerminus" and then I went online and the script seemed to be working but it will not work for everyone else because their name will not be included within the script. Any ideas?

2 comments
Is this script in a GUI button?
Yes.