I wanna change the local player camera pos to a set part on my workspace when the player hits the part, I managed to write the script below, which works, but instead of changing only the local player camera pos, it changes all players camera position instead. How can I make it only changes the local player camera?
local camera = workspace.CurrentCamera local part = workspace.cam workspace.Test.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent)then camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = part.CFrame end end)
The script is local and is storaged under StarterPlayer/StarterPlayerScripts
You put cam instead on camera Hope this fixes it
local camera = workspace.CurrentCamera local part = workspace.camera workspace.Test.Touched:Connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent)then camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = part.CFrame end end)
If it helped, validate my answer please!
Here's the solution:
Add an if statement
to the start of the fuction checking if who touched the part has the same name of the local player, if yes, run your code, else do something that you want or just dont.
The function would look like this:
local player = game.Players.LocalPlayer local camera = workspace.CurrentCamera local part = workspace.camera workspace.Test.Touched:Connect(function(hit) if player.Name == hit.Parent.Name then if game.Players:GetPlayerFromCharacter(hit.Parent)then camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = part.CFrame end end end)
Sorry for the late response, but if you were having the same issue, np!