How do I get the local player's name from a folder?

So I’m trying to make a golf game. And this script is going to make the camera go over the player’s golf ball.
Here’s the script:

local Camera = workspace:WaitForChild(“Camera”)

local GolfBalls = workspace.GolfFolder

local PlayerName = game.Players.LocalPlayer.Name

Camera.CameraType = “Scriptable”

for i, v in pairs(GolfBalls:GetChildren()) do

local GolfCam = workspace.CamFolder.PlayerName

if v.Name == game.Players.LocalPlayer.Name then

Camera:Interpolate(GolfCam.CFrame, v.PlayerName.CFrame, 1)

v.PlayerName.Pos.Value = GolfCam.Position

wait(0)

end

end

When I run the script I just get a error saying PlayerName is not a valid member of folder.
Help would be appreciated. :smiley:

What if you tried doing this?

local GolfCam = workspace.CamFolder[PlayerName]
1 Like

Now it works! Thank you very much