So, I would like to Attach the Camera to a Part. I've gotten a few suggestions and I have no idea where to begin anymore and the Roblox Wiki isn't helping me. How do I do this?
What I have so far:
function player()
repeat wait() until game.Workspace.CurrentCamera
local cam = game.Workspace.CurrentCamera
cam.CameraSubject = game.Workspace.Cheese
cam.CameraType = ("Attach")
cam.FieldOfView = 50
end
game.Players.PlayerAdded:connect(player)
It is a LocalScript in StarterGui, but now I know that the PlayerAdded event does not work in a LocalScript. What do I do??
Use two scripts to get around this problem, a SERVER script that uses the PlayerAdded event to insert the LocalScript into StarterGui, and a LOCALscript that actually contains the code. The Localscript should be a child of the server script.
First, the server script:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) script.LocalScript:clone().Parent = character --change this to redirect to the player's StarterGui end) end)
This inserts the Localscript into the Player. Now you can put your code into the Localscript. When a Player spawns, the server script will trigger and put the Localscript in the Player, which will let the Localscript run. I hope this helps!