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.
01 | function OnTouch(HIT) |
02 | wait( 1 ) |
03 | Player.CameraMaxZoomDistance = 1 |
04 | Player.OnTouch:connect( function (HIT) |
05 | wait(WaitTime) |
06 | local Torso = Character:FindFirstChild( "Torso" ) |
07 | if Torso ~ = nil then |
08 | Torso.CFrame = CFrame.new(Position) |
09 | end |
10 | end ) |
11 | 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:
01 | function onTouched(part) |
02 | local h = part.Parent:findFirstChild( "Humanoid" ) |
03 | if h~ = nil then |
04 | Local Player = game:GetService( "Players" ).LocalPlayer |
05 | local Torso = Player.Character:WaitForChild( "Torso" ) |
06 | local ZoomDistance = 1 |
07 | local Position = Vector 3. new() -- put your position here in the () if it won't work take of Vector3.new |
08 | Player.CameraMaxZoomDistance = 1 |
09 | if Torso ~ = nil then |
10 | Torso.CFrame = CFrame.new(Position) |
11 | end |
12 |
13 | end |
14 | end |
15 | script.Parent.Touched:connect(onTouched) |
~Greatneil80~
(remember to accept answer if it works)