Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My NPC will not give any Gold, no errors in Output. It's ment to give gold which go to stats. Help?

function Reward()
	Humanoid = script.Parent:FindFirstChild("Humanoid")
	if Humanoid ~= nil then
		Creator = Humanoid:FindFirstChild("creator")
		if Creator ~= nil then
			if Creator.Value ~= nil then
			local leaderstat = Creator.Value:FindFirstChild("leaderstat")
			if leaderstat ~= nil then
				if Creator.Value.Character ~= nil then
					leaderstat.Jewel.Value = leaderstat.Jewel.Value + 100
					end
				end
			end
		end
	end
end

script.Parent.Humanoid.Died:connect(Reward)

Location of what i'm trying to get too: game.Players.LocalPlayer.leaderstat.Jewel.Value

NOTE: No errors in output :/

2 comments

0

Bump.

0

What is the 'Creator.Value'?

1 answer

Your code is confusing please refine what you want to happen. I think this is what you want?

LOCAL SCRIPT

game.Players.LocalPlayer.Character.Humanoind.Died:connect(function()
	if game.Players.LocalPlayer:FindFirstChild("leaderstats") and game.Players.LocalPlayer:FindFirstChild("leaderstats"):FindFirstChild("Jewel") then
		game.Players.LocalPlayer.leaderstats.Jewel.Value = game.Players.LocalPlayer.leaderstats.Jewel.Value + 100
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.