Force ThirdPerson for two players

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

On line 31 i need the camera for Player, and charholdinghb’s camera to force thirdperson for those two and force first person on the animation ending

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Remote events for the local player, and checking dev fourms

Code:

wait(0.1)

local fhitbox = script.Parent.Parent
local prompt = script.Parent
wait(0.2)
local charholdinghb = script.Parent.Parent.Parent
local knife = game.ReplicatedStorage.WeaponsFinisher.KnifeFinisher.Handle
--//Sounds//--
local bonecrack = script.Sounds.BoneCrack
local dropsound = script.Sounds.Drop
local punchsound = script.Sounds.Punch
local bodydropsound = script.Sounds.BodyDrop
local stabsound = script.Sounds.Stab
--//KilledAnimations//--
local killed1anim = script.Killed.Killed1
local kild1track = charholdinghb.Humanoid:LoadAnimation(killed1anim)
local killed2anim = script.Killed.Killed2
local kild2track = charholdinghb.Humanoid:LoadAnimation(killed2anim)
local killed3anim = script.Killed.Killed3
local kild3track = charholdinghb.Humanoid:LoadAnimation(killed3anim)
--//KillingAnimations//--
local killing1anim = script.Killing.Killing1
local killing2anim = script.Killing.Killing2
local killing3anim = script.Killing.Killing3



prompt.Triggered:Connect(function(player)
	if charholdinghb.Humanoid.Health > 0 then
		
		-- make camera third person for "Player" & "charholdinghb"
		
		local RandomAnimation = math.random(1,3)

		if RandomAnimation == 1 then
			local kilng1track = player.Character.Humanoid:LoadAnimation(killing1anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild1track:Play()
			kilng1track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it with neck crack <3
			charholdinghb.Humanoid.Health = 5
			bonecrack:Play()
			wait(1) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			dropsound:Play()
			wait(1.05) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0
			charholdinghb.HumanoidRootPart:Destroy()


		elseif RandomAnimation == 2 then
			local kilng2track = player.Character.Humanoid:LoadAnimation(killing2anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild2track:Play()
			kilng2track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it well so it sounds in sync <3
			charholdinghb.Humanoid.Health = 5
			dropsound:Play()
			wait(1) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			punchsound:Play()
			wait(1.05) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0	
			charholdinghb.HumanoidRootPart:Destroy()

		elseif RandomAnimation == 3 then
			local clone = knife:Clone()
			local playerkilling = player.Character
			local righarm = playerkilling["Right Arm"]
			clone.Parent = playerkilling
			local moto = Instance.new('Motor6D')
			moto.Parent = playerkilling
			moto.Part0 = righarm
			moto.Part1 = clone

			local kilng3track = player.Character.Humanoid:LoadAnimation(killing3anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild3track:Play()
			kilng3track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it well so it sounds in sync <3
			charholdinghb.Humanoid.Health = 5
			stabsound:Play()
			wait(1.05) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			stabsound:Play()
			wait(1) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0
			charholdinghb.HumanoidRootPart:Destroy()
			clone:Destroy()
		end
	end
end)

it is a script, NOT a local script

1 Like

To force third person and first person, you can modify the CameraMode. While the client camera is not modifyable on the server, these are properties of the player and can be modified.

local function makeThirdPerson(player: Player)
    player.CameraMode = Enum.CameraMode.Classic
    player.CameraMinZoomDistance = 20
end

local function makeFirstPerson(player: Player)
    player.CameraMinZoomDistance = 0
    player.CameraMode = Enum.CameraMode.LockFirstPerson
end

i just tested it and for some reason it does absolutely nothing. I will try to fix it

after some looking, i get this: "CameraMode is not a valid member of Model “Workspace.Player2” "

how would i get the camera?

Sorry, that’s the character. You need to do it on the Player object under Players. You can retrieve it through the :GetPlayerFromCharacter() method on the Players service.

local players = game:GetService("Players")

local playerObj = players:GetPlayerFromCharacter(character)
makeThirdPerson(playerObj)

GetPlayerFromCharacter is not a valid member of Player “Players.Player2”

No, it’s a function of the Players service. But, if you already have access to Players.Player2, you may not even need it, the whole point was to be able to retrieve the Player object. Can you send your updated code?

wait(0.1)

local fhitbox = script.Parent.Parent
local prompt = script.Parent
wait(0.2)
local charholdinghb = script.Parent.Parent.Parent
local knife = game.ReplicatedStorage.WeaponsFinisher.KnifeFinisher.Handle
--//Sounds//--
local bonecrack = script.Sounds.BoneCrack
local dropsound = script.Sounds.Drop
local punchsound = script.Sounds.Punch
local bodydropsound = script.Sounds.BodyDrop
local stabsound = script.Sounds.Stab
--//KilledAnimations//--
local killed1anim = script.Killed.Killed1
local kild1track = charholdinghb.Humanoid:LoadAnimation(killed1anim)
local killed2anim = script.Killed.Killed2
local kild2track = charholdinghb.Humanoid:LoadAnimation(killed2anim)
local killed3anim = script.Killed.Killed3
local kild3track = charholdinghb.Humanoid:LoadAnimation(killed3anim)
--//KillingAnimations//--
local killing1anim = script.Killing.Killing1
local killing2anim = script.Killing.Killing2
local killing3anim = script.Killing.Killing3

function makeThirdPerson(playerObj, charholdinghb)
	playerObj.CameraMode = Enum.CameraMode.Classic
	playerObj.CameraMinZoomDistance = 20
	
	charholdinghb.CameraMode = Enum.CameraMode.Classic
	charholdinghb.CameraMinZoomDistance = 20

	print("changed to third person")
end

function makeFirstPerson(playerObj, charholdinghb)
	playerObj.CameraMinZoomDistance = 0
	playerObj.CameraMode = Enum.CameraMode.LockFirstPerson
	
	charholdinghb.CameraMinZoomDistance = 0
	charholdinghb.CameraMode = Enum.CameraMode.LockFirstPerson
end

prompt.Triggered:Connect(function(player)
	if charholdinghb.Humanoid.Health > 0 and player.Character:FindFirstChild("Humanoid").Health > 0 then
		
		local playerObj = player:GetPlayerFromCharacter(player.Character)
		makeThirdPerson(playerObj, charholdinghb)
		
		local RandomAnimation = math.random(1,3)

		if RandomAnimation == 1 then
			local kilng1track = player.Character.Humanoid:LoadAnimation(killing1anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild1track:Play()
			kilng1track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it with neck crack <3
			charholdinghb.Humanoid.Health = 5
			bonecrack:Play()
			wait(1) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			dropsound:Play()
			wait(1.05) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0
			charholdinghb.HumanoidRootPart:Destroy()


		elseif RandomAnimation == 2 then
			local kilng2track = player.Character.Humanoid:LoadAnimation(killing2anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild2track:Play()
			kilng2track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it well so it sounds in sync <3
			charholdinghb.Humanoid.Health = 5
			dropsound:Play()
			wait(1) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			punchsound:Play()
			wait(1.05) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0	
			charholdinghb.HumanoidRootPart:Destroy()

		elseif RandomAnimation == 3 then
			local clone = knife:Clone()
			local playerkilling = player.Character
			local righarm = playerkilling["Right Arm"]
			clone.Parent = playerkilling
			local moto = Instance.new('Motor6D')
			moto.Parent = playerkilling
			moto.Part0 = righarm
			moto.Part1 = clone

			local kilng3track = player.Character.Humanoid:LoadAnimation(killing3anim)
			player.Character.HumanoidRootPart.CFrame = charholdinghb.HumanoidRootPart.CFrame * CFrame.new(0,0,1)
			kild3track:Play()
			kilng3track:Play()
			prompt.Enabled = false
			charholdinghb.HumanoidRootPart.Anchored = true
			player.Character.HumanoidRootPart.Anchored = true
			wait(0.3) -- time it well so it sounds in sync <3
			charholdinghb.Humanoid.Health = 5
			stabsound:Play()
			wait(1.05) -- time this with killing anim
			player.Character.HumanoidRootPart.Anchored = false
			stabsound:Play()
			wait(1) -- time this with the killed anim
			charholdinghb.Humanoid.Health = 0
			charholdinghb.HumanoidRootPart:Destroy()
			clone:Destroy()
		end
	end
end)


	

sorry bout this

method 1) = Forcing the Player into "Third Person" while they're in "First Person"

idk if you can read or not but uhhhh
image
image
i have tried. can you read my message before commenting?

Same thing?

If its a script, use remote events that you already tried, mind me seeing the remote event script?

1 Like

your code is almost unreadable, and why are you using “wait()”?

You need to make a new local script, because you cant on the server

1 Like

because i wrote it quickly. can you help me or just antagonize why i used a “wait()” :expressionless:

you could on a server, i have the player and everything i just need to know how to change the camera enums and that

You need to do that on their client

  1. use a remote event to communicate between client and the server, you cannot change the client’s camera from a server script

  2. receive the remote event in a local script, and then change the camera mode

1 Like

Looks like you are trying to modify the zoom distance of charholdinghb, which appears to be a character, not a player object.

This is unneccessary because you already have the player object.

You’d only need to do that when modifying the camera object itself, but you can modify the CameraMinZoomDistance and CameraMode on the server as they are properties of the player.

1 Like