I'm making a game and gold is the currency. I want to make NPC's that if you kill you will be awarded a certain amount of gold. I currently don't have the knowledge to do this, all I have is this script:
amnt = 50000
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Gold")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end
script.Parent.Touched:connect(onTouched)
I am a extreme newbie to Lua so I tried taking the easy way out and just making it so if you touch the NPC then it will award you the gold; but that causes many problems. Could anyone help me? Greatly appreciated.
