Hey programmers! I am in need of assistance today.
I am trying to make a scavenger hunt quest and when the users touches 2 orbs then a message pops up showing that they need to return to the NPC and collect there reward.
BasePart’s do not contain a property known as Touched, you can either add an attribute for that or make a BoolValue Instance and just name it a part’s Name, then set the value to true, then when it’s doing the checking, refer the two BoolValues.
The easy, but cheatable way:
Assuming script.Parent is some type of GUI, you can add 2 BoolValue objects to it and do something like script.Parent.Orb1Touched.Value = true in each of the Touched handlers. Then you could add some code to listen for value changed on those BoolValue objects and if they both are set to true, then give the reward.
The more complex but more secure way (and more correct):
Add a RemoteEvent to replicated storage and fire the event to the server each time the player touches an orb. A server script can monitor the touches and save the state per player. When the server handles a remote event, it can check to see if both orbs are touched and give the reward.
Touched is a built-in function for BaseParts used for collision detection. You are correct that its not a property in itself but it does exist. More info: BasePart | Roblox Creator Documentation
What the OP needs to do is pass an argument in the Touched connection to get the part that was doing the touching and check to see if that part is a descendant of a player’s character or if it just contains a humanoid, whichever their preference.
This can be done like so:
workspace.Part.Touched:Connect(function(partThatTouched)
if partThatTouched.Parent:FindFirstChild("Humanoid") then
-- A humanoid touched the part, do something with the part..
end
end)
I also like the above comment that mentioned using a RemoteEvent to let the server know it was touched so it can keep track, since you dont want to trust the client, or else an exploiter can get every item instantly.