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 9 years ago

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

1function onTouch(part)
2    local player = game.Players:GetPlayers(part.Parent)
3    if player ~= nil then
4        player.CamerMode = "Classic"
5    end
6end
7 
8script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 9 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.

1function onTouch(part)
2    local player = game.Players:GetPlayerFromCharacter(part.Parent)
3    if player ~= nil then
4        player.CameraMode = "Classic"
5    end
6end
7 
8script.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 — 9y
0
Oh, CameraMode is misspelt. Fixed! Spongocardo 1991 — 9y
0
Umm.. i didn't saw it too. Work perfect, thanks for help. DevKarolus1 70 — 9y
0
No problem. Spongocardo 1991 — 9y
Ad

Answer this question