0

# How would I find the local player in a server script?

Edited 7 days ago

I am making a script, that every time the npc dies, the player gets +10 coins to their leader stats named "coins". I use the player added function but it only adds plus 10 once. then when the npc health value reaches 0 again, it doesn't add +10. Please help!

local health = script.Parent --script is in a health value of my npc

health.Changed:Connect(function() if health.Value <= 0 then local currentposition = script.Parent.Parent.HumanoidRootPart.CFrame health.Value = 10 script.Parent.Parent.HumanoidRootPart.CFrame = turtlerespawn.CFrame

    --Utter confusion--

local player = plr
print(player.Name)
print("Plus 10")
end)
wait(5)
script.Parent.Parent.HumanoidRootPart.CFrame = currentposition
end

----------------------------------------------------------------------------------------


end)

0
the coded part is the part that i'm trying to find the local player in. Carlowskey 11 — 7d