Character is not a valid member of Players "Players"

Everytime I join my game to test out my Camera position that I’m trying to implement I recieve an error
Character is not a valid member of Players “Players”, I’m not sure what I did wrong there but here’s the code.

local Players = game:GetService("Players")
local Character = Players.Character or Players.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local PlayButton = script.Parent.ImageButton
local Frame = script.Parent.Frame

repeat wait()
	  Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
Camera.CFrame = workspace.GameFolder.CameraFolder.CameraPart.CFrame

PlayButton.MouseButton1Click:Connect(function()
	Camera.CameraType = Enum.CameraType.Custom
	PlayButton:Destroy()
	Frame:Destroy()
end)

What did I do wrong here?

Is this a Server Script or a LocalScript?

Scratch that:

you are pretty much doing
game.Players.Character,
its
game.Players.LocalPlayer.Character

game.Players is a Service as stated below by @GuySalami

2 Likes

The service Players, doesn’t have a character, an individual Player has a Character though

1 Like

Works perfectly fine now, thanks! @GuySalami, @DasKairo.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.