You can write your topic however you want, but you need to answer these questions:
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
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)
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
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)
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)
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.