First of all, StarterPlayer refers to a service that allows you to set default properties for the player object. StarterGui is the same thing except it sets default properties for the PlayerGui object. So if you want to change these objects during run-time, instead of StarterPlayer use local player = game.Players.LocalPlayer and instead of StarterGui use local gui = player:WaitForChild("PlayerGui").
local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui")
while true do
if gui.Frame.Visible == true then
player.CameraMaxZoomDistance = 10
player.CameraMinZoomDistance = 10
player.CameraMode = "Classic"
wait(1)
end
if gui.Frame.Visible == false then
script.Parent.Parent.CameraMode = "LockFirstPerson"
wait(1)
end
end
Now, as for the changing camera mode when you touch something you need to use the Touched event . Not sure how the script you made above relates to what you want to do, but changing the camera mode when a part is touched would look something like this in a LocalScript:
local part = workspace.Part
local player = game.Players.LocalPlayer
part.Touched:Connect(function(touch)
if touch.Parent.Name == player.Name then
player.CameraMode = "LockFirstPerson"
end
end)
However you would like to integrate what you have made so far with the touched event is up to you. Good luck!
1 comment
https://developer.roblox.com/en-us/api-reference/event/BasePart/Touched