Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making a unforcefirstperson touchable button?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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

0
thank you, it worked! sweetlittlegirlohhl -22 — 7y
0
Good. KingLoneCat 2642 — 7y
Ad

Answer this question