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

help with getting currency after killing a boss?

So this is a local script inside of a text button in a gui. I need help because it doesnt work and I'm not great at scripting.

Script:

local Minato = game.Workspace.NPCbosses.Minato
local Health = Minato.Humanoid.Health
local Ryo = game.Players.LocalPlayer.leaderstats.Ryo.Value
local Exp = game.Players.LocalPlayer.PlayerInfo.PlayerLevel.Value
local RyoReward = game.Workspace.NPCmissions.MinatoMission.Data.RyoReward.Value
local ExpReward = game.Workspace.NPCmissions.MinatoMission.Data.ExpReward.Value

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible = true
end)

if script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible = true then
	if Health <= 0 then
		Ryo + RyoReward
	end
	
	if Health >= 0.1 then
		Exp + ExpReward
	end
end

FYI this is a naruto game so thats why the boss is named Minato and why the currency is Ryo :)

1 comment

0

You could just past the code inside you question with code block.

1 answer

This is just a repost of this guy's or gal's script and some tips !

local Minato = game.Workspace.NPCbosses.Minato
local Health = Minato.Humanoid.Health
local Ryo = game.Players.LocalPlayer.leaderstats.Ryo.Value
local Exp = game.Players.LocalPlayer.PlayerInfo.PlayerLevel.Value
local RyoReward = game.Workspace.NPCmissions.MinatoMission.Data.RyoReward.Value
local ExpReward = game.Workspace.NPCmissions.MinatoMission.Data.ExpReward.Value

script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Visible = false
	script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible = true
end)

if script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible = true then
	if Health <= 0 then
		Ryo + RyoReward
	end
	
	if Health >= 0.1 then
		Exp + ExpReward
	end
end

Also , on line 13 , if statments are supposed to have 2 equal signs like this : ==

So It is supposed to be if script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible == true then

NOT this

if script.Parent.Parent.Parent.UnusedFrame.DefeatedUndefeated.Visible = true then

Also on Line 2 , Defining Health Actually Saves that Bosses Current Health they had. So I recommend you delete that line and any other line in the script that uses the Variable Heath Should Be Deleted and replace with Humanoid.Health , to get the Health the currently have , rather than getting a saved heath number they had at the start of the script.

Basically , Lets say the boss's health was 100 and you defined health as Healt = Humanoid.Health.

The Variable Heath Would Then Be Saved as 100 For the rest of the script until updated , And from looking at this script , Lines 2 ,14 ,and 18 dont need that !

Welp , that's all the tips I got for you here! Make sure there are not Spelling , grammar , or capitalization mistakes in your code !

-- Good Day to you !

5 comments

0

Thanks a lot! I will try this out soon :)

0

accept my answer is you accept it.

0

it did not work :(

0

ooof !

0

what is the error !

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