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

What's wrong with ontouch third person camera script?

Asked by 8 years ago

Now im trying back to third person camera, but i think i have done something wrong. Of course it's onTouch.

function onTouch(part)
    local player = game.Players:GetPlayers(part.Parent)
    if player ~= nil then
        player.CamerMode = "Classic"
    end
end

script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 8 years ago

I think the method you're looking to use is GetPlayerFromCharacter.

GetPlayers gets all the players in the game and returns them in an array,while GetPlayerFromCharacter essentially gets the player from the player's character, if there is a player associated with said character.

function onTouch(part)
    local player = game.Players:GetPlayerFromCharacter(part.Parent)
    if player ~= nil then
        player.CameraMode = "Classic"
    end
end

script.Parent.Touched:connect(onTouch)

I hope my answer helped you. If it did, be sure to accept it.

0
Nope, still can't back from first person to third person. DevKarolus1 70 — 8y
0
Oh, CameraMode is misspelt. Fixed! Spongocardo 1991 — 8y
0
Umm.. i didn't saw it too. Work perfect, thanks for help. DevKarolus1 70 — 8y
0
No problem. Spongocardo 1991 — 8y
Ad

Answer this question