Can you assign 2 values to an IntValue?

  1. What do you want to achieve?

I have a quest system that utilizes IntValues for each quest, aka, “Num”. So let’s say that for quest one, Num = 1, then Num must = 1 in the enemy’s data… if not then killing the enemy will not count towards the completion of the quest.

More specifically, if in quest 2, Num = 2, but Num = 1 in the enemy’s data, then it won’t count… I want to be able to create a new quest with a different Num value, but still, use Num = 1 enemies to complete the quest.

  1. What solutions have you tried so far?

I’ve tried adding another “Num” IntValue to the enemy data = 2 but that didn’t work. I’ve also tried having a “Num2” IntValue but that didn’t work either.

I’m not quite sure how to accomplish what I’m trying to achieve and would greatly appreciate the help of the many knowledgable individuals on the DevForum. :slight_smile:

ServerScript Quest Script
Within this script you’ll see the reward(s) for completing a quest, as you can see the “Num” is = to whatever “Num” the quest number is assigned.

game.Players.PlayerAdded:connect(function(player)
	local Lead = Instance.new("Folder")
	Lead.Name = "Quest"
	Lead.Parent = player
	local Num = Instance.new("IntValue")
	Num.Name = "Num"
	Num.Value = 0
	Num.Parent = Lead
	local Kills = Instance.new("IntValue")
	Kills.Name = "Kills"
	Kills.Value = 0
	Kills.Parent = Lead
	local Max = Instance.new("IntValue")
	Max.Name = "Max"
	Max.Value = 1
	Max.Parent = Lead
	
Kills.Changed:connect(function()
	if player.Quest:WaitForChild("Num").Value == 1 then
		if player.Quest:WaitForChild("Kills").Value >= player.Quest:WaitForChild("Max").Value then
			player.Quest:WaitForChild("Num").Value = 0
			player.Quest:WaitForChild("Kills").Value = 0
			player.Quest:WaitForChild("Max").Value = 1
				player.PlayerGui:WaitForChild("QuestBar"):Destroy()
			player.Data.Exp.Value = player.Data.Exp.Value + 1000
			player.Data.Beli.Value = player.Data.Beli.Value + 250
		end
		end
			--new quest
	end)
end)

Screen Shot 2022-07-06 at 1.54.03 PM

"Main" Script within “Accept” GUI button
Here you’ll see the quest “Num” & how many kills you need to complete it. Within the Screen GUI, all “Num” values will be = to the quest “Num” in the ServerScript Quest Script.

script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr)
	local GUI = script.Parent.Parent.QuestBar:Clone()
	GUI.Parent = plr.PlayerGui
	local Num = plr:WaitForChild("Quest"):WaitForChild("Num")
	Num.Value = 1 --- quest number
	local Max = plr:WaitForChild("Quest"):WaitForChild("Max")
	Max.Value = 5 --- kills needed
	local Kills = plr:WaitForChild("Quest"):WaitForChild("Kills")
	Kills.Value = 0 --- start kill amnt
end)

Screen Shot 2022-07-06 at 1.52.47 PM

The place (which I believe) to be the issue is the Enemy’s data, “Sphere” is my enemy NPC, it’s Num = 1… but when the Player’s Num =/ 1 then killing a Num = 1 NPC won’t count towards the Num = 2 quest.

Long story short, I want the enemy’s (Num = 1) to count as kills for Quest that has Num = 2. I did use this model and then expanded on/customized it - I’ve provided the link so you could have a more hands-on approach.

Thanks for your help!

Figured out how to do it!

In the Reward Script of the Enemy, do >= instead of == for Num value :slight_smile: