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

How can I toggle StarterPlayer FPS on/off on roblox studio?

Asked by 9 years ago

I have a script, I edited it from a free model.. I added in the codes after it shows "e" and I changed it from (Player = script.Parent.Parent) to (Players = Players.LocalPlayer) Is that right?. Can someone please help? I want it so when someone presses E they can either toggle from FPS mode to classic and press again to change from classic to FPS. And I left the original author there to show I didn't EXACTLY create it..

Players = Players.LocalPlayer
mouse = Players:GetMouse()

function onKeyDown(key)
key = key:lower()
if Players.LocalPlayer.Open.Value == false then
    if key == "e" then --start
        game.StarterPlayer.CameraMode.LockFirstPerson = false
        game.StarterPlayer.CameraMode.Classic = true
    end
elseif Players.LocalPlayer.Open.Value == true then
    if key == "e" then  --E is the key to open and close
        game.StarterPlayer.CameraMode.Classic = false
        game.StarterPlayer.CameraMode.LockFirstPerson = true
        end
    end 
end


mouse.KeyDown:connect(onKeyDown)

--IciFlame

1 answer

Log in to vote
0
Answered by 9 years ago

If you are doing a LocalPlayer you must make the script in a local script. Also, regarding the Player = Players.LocalPlayer. That should be

local Player = game.Players.LocalPlayer

The function should also be

function onKeyDown(key)
    key = key:lower()
    if Player.Open.Value == false then
        if key == "e" then --start
            game.StarterPlayer.CameraMode.LockFirstPerson = false
            wait()
            game.StarterPlayer.CameraMode.Classic = true
        end
    elseif Player.Open.Value == true then
        if key == "e" then  --E is the key to open and close
                game.StarterPlayer.CameraMode.Classic = false
            wait()
            game.StarterPlayer.CameraMode.LockFirstPerson = true
        end
    end
end

Remember this HAS to be in a LocalScript.

0
Did not work, and is in a LocalScript in starterpack. 789zaya 0 — 9y
Ad

Answer this question