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

What's wrong with ontouch third person camera script?

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

✓ Accepted answer

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.

4 comments

0

Nope, still can't back from first person to third person.

0

Oh, CameraMode is misspelt. Fixed!

0

Umm.. i didn't saw it too. Work perfect, thanks for help.

0

No problem.

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