The goal of this script is to tell when a player kills another player, and make a gui change accordingly. The problem is, it only functions sometimes, when the player first joins, and then randomly after that point. No errors. Local script inside of a gui
game:GetService('Players').LocalPlayer.CharacterAdded:connect(function(charModel)
local Value1 = charModel:WaitForChild("SwordPart"):WaitForChild("Killed")
Value1.Changed:connect(function()
local Sound = script:WaitForChild("indicator")
local Frame = script.Parent.Frame
local Plrname = script.Parent.Frame.PlrName
Plrname.Text = Value1.Value
Frame.Visible = true
Sound:Play()
wait(5)
Frame.Visible = false
end)
end)
Script inside of a part
local Obj = script.Parent
Obj.Touched:connect(function(Hit)
if Hit.Parent:findFirstChild("Humanoid") then
Hit.Parent.Humanoid:TakeDamage(10)
if Hit.Parent.Humanoid.Health == 0 then
script.Parent.Killed.Value = Hit.Parent.Name
end
end
end)

2 comments
Is the 'Obj' here a projectile? (e.g. Bullet) If so, I don't think there's something wrong with it.
obj is a part that the player holds