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

Making a unforcefirstperson touchable button?

So i asked this question but it is still unsolved. ALSO, I ALREADY HAVE MY GAME IN LOCK FIRST PERSON MODE (just to say). I wanted to make a button that when you touch it, it lets you unlock first person mode and lets you zoom out. i made a script that didnt work and GreatNeil80 gave me another, but it doesnt work so here is the script he gave me.

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)

please help

1 answer

✓ Accepted answer

Hey sweetlittlegirlohhl,

So, If your game is already in Lock First Person Mode then if I'm not mistaken the Player's CameraMode has been changed to LockFirstPerson. Then, all you need to do when the Player touches the part is to set that property of the Player back to Classic. In order for this to happen you need to just identify that it was a Character that touched the part and then locate the Player from the ServerScript. Below is an example of how you would accomplish this.

####ServerScript under the Part for .Touched Event

local part = script.Parent;
local players = game:GetService("Players");

part.Touched:Connect(function(obj)
	local hum = obj.Parent:FindFirstChild("Humanoid");
	if hum then
		local char = obj.Parent;
		local plr = players:GetPlayerFromCharacter(char);
		plr.CameraMode = Enum.CameraMode.Classic;
	end
end)

##Well, I hope I helped in one way or another. Have a great day/night.

~~ KingLoneCat

2 comments

0

thank you, it worked!

0

Good.

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