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.
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
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.
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)
yea it should work i think let me know
also you didnt have to addd that killerhumanoid thing i just realized i wasnt look through the whole code.
The kill cam script still does not work.
Does it just flat out not switch to the killer?
Yeah, the text is working fine but the camera isn’t.
remove:
wait(5)
frame.Visible = false
camera.CameraSubject = humanoid
and lets see what happens