The script’s parent is the click detetcor
I never expected there to be, I was simply correcting his code stated above where he did use a click detector.
Oh I see, disregard my last comment then.
Keep with my code, see if the check function works, and then replace my function call with your click one.
Thats weird, so i do get prints, but the problem is that i dont have the quest value and yet its printing “1”
if player:FindFirstChild("Quest") then
print ("1")
else
print("2")
How are you adding the quest value to the player in the first place?
In the script with an Instance.new
So basically the script makes a quest value then if u already have a quest value then u cant get another one. Because whats happening is that i can spam click the npc and get multiple quest values
Do you mean like checking the Quest Int value and if value is greater than 0, then you don’t want to run the rest of the function?
No im checking if the player has the int value called “Quest” not the value of it
script.Parent.MouseClick:Connect(function(player)
if not player:FindFirstChild("Quest") then
local newQuest = Instance.new('IntValue',player)
newQuest.Name = 'Quest'
end
end)
Is this what you were trying to achieve?
Yea, i had something similar to it, however it didnt work for some reason
Oh, alright. Try that one out.
It didn’t work could it be that i am trying to check if 2 values exist?
i forgot to add that im also checking for another intvalue
script.Parent.MouseClick:Connect(function(player)
if not player:FindFirstChild("Quest") or ("Tutorial") then
local newQuest = Instance.new('IntValue',player)
newQuest.Name = 'Quest'
end
end)
Are you using a LocalScript or a normal Script (server script)?
That would’ve helped form the start. This is the setup you should have.
Yes, it is possible to do that with both of those values.
script.Parent.MouseClick:Connect(function(player)
if not player:FindFirstChild("Quest") or player:FindFirstChild("Tutorial") then
local newQuest = Instance.new('IntValue',player)
newQuest.Name = 'Quest'
end
end)
Oh so i need to add FindFirstChild for the 2nd value? let me see if it works
Sorry just to clarify, you want them to be able to get the quest whilst they have the tutorial or not?
So if they have the tutorial i dont want them to get a quest
Alright, use this.
script.Parent.MouseClick:Connect(function(player)
if not player:FindFirstChild("Quest") and not player:FindFirstChild("Tutorial") then
local newQuest = Instance.new('IntValue',player)
newQuest.Name = 'Quest'
end
end)
Computers are dumb, so you have to be explicit in what you order it to do.
So, while your line here makes sense to humans:
if not player:FindFirstChild("Quest") or ("Tutorial") then
the second logical argument (“Tutorial”) will just return true always.
You see, an IF statement simply checks if something is true or exists;
So the following…
if "" then -- string value (exists)
if 1 then -- number value (exists)
if game.Workspace then -- instance (exists)
are the same as saying…
if true then -- bool value
because all of the above are valid values - they exist
whereas…
if nil then -- nil / null (doesn't exist)
if game.Workspace:FindFirstChild("SomethingThatDoesntExist") then -- nil instance (doesn't exist)
are the same as
if false then -- bool value (exists, but is false - so the following code will never run)