Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I was making a unforce first person button?

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!

1 answer

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)

5 comments

0

It does not let me zoom out when touched

1

change the zoom distance

0

i already did that

0

oh and also, i already have my game camera mode set to lock first person i dont know if that matters though

1

okay, then remember for position, the variable, make it either CFrame or remove the vector3.new

This discussion is preserved as it was. New answers, comments, and votes are closed.