Hi, I am making a quest script and line 23, I will note where it is is not working. It just says an error on line 23 and nothing else.
script.Parent.Triggered:Connect(function(player)
local QuestGiver = math.random(1, 2)
local HasQuest = Instance.new("NumberValue")
HasQuest.Parent = player
HasQuest.Name = "HasQuest"
HasQuest.Value = 0
if QuestGiver == 1 then
if HasQuest.Value == 0 then
HasQuest.Value += 1
print("1")
-- This quest is to get 100 coins and win 100 coins.
local Count = Instance.new("IntValue")
Count.Name = "Count"
Count.Value = 0
Count.Parent = player
local leaderstats = player.leaderstats
local Coins = leaderstats.Coins
local PastCoinValue = Coins.Value
task.wait(Coins.Value == PastCoinValue + 100) -- error here
Coins.Value += 100
HasQuest -= 1
else
return
end
end
if QuestGiver == 2 then
if HasQuest == 0 then
HasQuest += 1
print("2")
-- This quest is to kill (X) amount of bots
local X = 5 -- X = number of bots to kill
local KillCounter = Instance.new("NumberValue")
KillCounter.Name = "KillCounter"
KillCounter.Value = 0
KillCounter.Parent = player
task.wait(KillCounter.Value == X)
HasQuest -= 1
else
return
end
end
end)
Alright let me do a in depth explanation
task.wait is a function that only takes numbers
Coins.Value is a number and so is PastCoinValue
If you compare them in a script they will make a true or false value
you are adding 100 to that value
then putting it into task.wait