so i have my game in force first person mode and i want to make a special button so that people who want to have their camera not in first person can zoom in and out. (when they step on the part)
this is the script i make but it doesnt work. Im not a very good scripter.
function OnTouch(HIT) wait(1) Player.CameraMaxZoomDistance = 1 Player.OnTouch:connect(function(HIT) wait(WaitTime) local Torso = Character:FindFirstChild("Torso") if Torso ~= nil then Torso.CFrame = CFrame.new(Position) end end) end)
please help me fix this as for i suck at scripting thanks!
Hi, I am greatneil80 and this is the list of items that needs to be fixed.. WaitTime isn't a thing, you didn't define it, it will give an error, index to global 'WaitTime' i suppose.. And Position isn't a thing so it will also say index to global 'Position'.. Player isn't defined just like WaitTime and neither is Position, Character isn't defined either.. I would do something like this..
Place this in the part that is touched:
function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then Local Player = game:GetService("Players").LocalPlayer local Torso = Player.Character:WaitForChild("Torso") local ZoomDistance = 1 local Position = Vector3.new()-- put your position here in the () if it won't work take of Vector3.new Player.CameraMaxZoomDistance = 1 if Torso ~= nil then Torso.CFrame = CFrame.new(Position) end end end script.Parent.Touched:connect(onTouched)
~Greatneil80~
(remember to accept answer if it works)