How to Detect if the killer/creator is Player or AI

Hello guys im here again and now the problem is easy but i tried all i can but its not enough

im making a detector and the problem is the script cant detect if its player or ai if player is work properly but on AI its not and get error

heres the code

local human = script.Parent:FindFirstChild("Humanoid")
local DiedExp = game.ReplicatedStorage:WaitForChild("DiedExp") 
local char = script.Parent

human.Died:Connect(function()
	local creator = human:FindFirstChild("creator")
	local killer = creator.Value
	local exp = killer.Stats.Exp
	local player = game.Players:GetPlayerFromCharacter(creator.Value)
	
	if killer and player then
		DiedExp:FireServer(exp)
	elseif not player then
		print("Its not player")
	end
end)

what do you think?

heres the error

image

What do you mean if it is an AI, do you mean a bot?

A way to detect it is by putting a string value in the players char and calling it team Then having the value as player and for the other Bot have the team value as Bot. Then detect the value and pit an if statement to judge whether to give xp or not

The error here is telling us that “Value” is not a value of creator

like zombie or something can kill you and its not player

how to i detect the character of AI and player

I would reccomend you look at my post above.

yes but when player another player its work properly

Just add a simple check to see if the “creator” tag exists.

local human = script.Parent:FindFirstChild("Humanoid")
local DiedExp = game.ReplicatedStorage:WaitForChild("DiedExp") 
local char = script.Parent

human.Died:Connect(function()
	local creator = human:FindFirstChild("creator")
    if creator then
	local killer = creator.Value
	local exp = killer.Stats.Exp
	local player = game.Players:GetPlayerFromCharacter(creator.Value)
	
	if killer and player then
		DiedExp:FireServer(exp)
	elseif not player then
		print("Its not player")
	end
   end
end)
1 Like

I already did that but same problem and when I print the player it’s nil I don’t know why.

Is “creator” an object value or a string value???

It’s object value so the value of it is the character of killer player

ok guys i already fix it by doing some experiment and thank god its done and working properly without error

I know this is over now but the post I made as just really dumb
Sorry if u confused ya
I just had a problem like this and realised
“OH object values exist”