Why is this "Kill Cam" not working?

Hello dev’s! I am working on a kill cam script and I got this weird error.

I really dont understand that error so I’m hoping that one of you dev’s do.
This is the Localscript:

local camera = game:GetService("Workspace").CurrentCamera
local frame = script.Parent:WaitForChild("Frame")
local player = game:GetService("Players").LocalPlayer or game:GetService("Players").PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
	local killer = character.Humanoid:FindFirstChild("creator")
	local killerCharacter = killer.Value.Character
	local killerName = killer.Value.Name
	if killer.Value then
		frame.Visible = true
		camera.CameraSubject = killerCharacter.Humanoid
		frame.TextLabel.Text = killerName.." killed you nub lol XDD"
		wait(5)
		frame.Visible = false
		camera.CameraSubject = humanoid
	end
end)

And if needed, this is the explorer:
MrFinkyDoodles's Place Number_ 25 - Roblox Studio 7_7_2021 6_59_10 PM

Thanks for all of your help!

What weapon are you using? Is it a official weapon by roblox?

I’m assuming this is because “creator” is nil inside of the Humanoid (meaning its not there). Make sure that it is created if not.

Its a custom Glock 17 I made with only unions.

I’ve seen this script before it only works because official roblox weapons tag humanoids.

Use the official roblox weapon kit as it tags player who kill others. That hopefully should fix the problem. There is nothing wrong with the script it’s just the weapon lol

FindfirstChild returns nil here. Add a check below this line like this:

if not killer then return end

Try this weapon and let me know if that works.
https://www.roblox.com/library/47433/Sword?Category=Models&SortType=Relevance&SortAggregation=AllTime&SearchKeyword=sword&CreatorId=0&Page=1&Position=1&SearchId=c37e1bf4-6f43-4907-aabc-755a5610b8bc

Do you think that it is possible to move the tag function over to the weapon I made?

yea just copy it from the sword look for a function called “taghumaniud” or something along those lines.

1 Like
function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end
1 Like

yea that’s it now call that function whenever you kill someone

You also need a function to destroy the tag though.

Uh. No you dont.

Debris:AddItem(Creator_Tag, 2)

automatically destroys the tag after 2 seconds

The text works but not the camera.

humanoid is defined to the player humanoid not the killhumanoid so do:

      local killerHumanoid = killerCharacter:FindFirstChild('Humanoid')

than replace camera.CameraSubject = humanoid with:

    camera.CameraSubject = killerHumanoid

Can you go more into depth? I already thought I defined the killers humanoid.

OH WAIT! So sorry I just missed that line of code. Wait let me put this code in roblox studio and see how it works.

Well I tried it and it works perfectly fine. Not sure what the issue is.

1 Like

So something like this is fine?

local camera = game:GetService("Workspace").CurrentCamera
local frame = script.Parent:WaitForChild("Frame")
local player = game:GetService("Players").LocalPlayer or game:GetService("Players").PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
	local killer = character.Humanoid:FindFirstChild("creator")
	if not killer then return end
	local killerCharacter = killer.Value.Character
	local killerHumanoid = killerCharacter:FindFirstChild("Humanoid")
	local killerName = killer.Value.Name
	if killer.Value then
		frame.Visible = true
		camera.CameraSubject = killerHumanoid
		frame.TextLabel.Text = killerName.." killed you nub lol XDD"
		wait(5)
		frame.Visible = false
		camera.CameraSubject = humanoid
	end
end)