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

trying to add currency and such to players stats when a npc boss is killed?

So in my rpg Im trying to add rewards (such as currency and exp and some gui crap) when I kill a "npc boss", and it doesnt work as expected since I am not great at scripting. This is the script I was thinking of: https://pastebin.com/raw/bTkrFFPC. Any help would be appreciated since this is one of the most important things the game needs.

1 answer

see if this script works, i think it doesn't work because you're making the ryo/exp value the same value as ryo/exp reward so u need to make the ryo/exp value + the ryo/exp reward and you can't just go straight to the value you need to use what the value parent is then put in .value hope this helps

local Itachi = script.Parent -- NPC Boss
local Humanoid = Itachi.Humanoid
local Ryo = game.Players.LocalPlayer.leaderstats.Ryo -- Game Currency (its a naruto game so its ryo)
local Exp = game.Players.LocalPlayer.leaderstats.Exp -- Exp since its a rpg
local ExpReward = Itachi.Data.Exp.Value -- exp I SHOULD get when I kill Itachi
local RyoReward = Itachi.Data.Ryo.Value -- ryo I SHOULD get when I kill Itachi
local UnfinishedRankings = game.Players.LocalPlayer.PlayerGui.MissionGUI.Frame.Unfinished --value 0/1 box before itachi is killed 
local FinishedRankings = game.Players.LocalPlayer.PlayerGui.MissionGUI.Frame.Finished --value 1/1 box after itachi is killed

if Humanoid.Health >= 0 then -- refers to if itachi dies
	Ryo.Value = Ryo.Value + RyoReward
	Exp.Value = Exp.Value + ExpReward
	MissionGuiName = game.ReplicatedStorage.MissionGUI.Name -- getting the ranking gui name
	Mission = game.Players.LocalPlayer.PlayerGui:FindFirstChild(""..MissionGuiName.."") -- searching in players playergui for it
	if Mission ~= nil then -- if player does have it then the remaining script should happen
		UnfinishedRankings.Value = FinishedRankings.Value-- changes 0/1 value to 1/1 value
	end 
	
end

1 comment

0

doesnt work :(

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