I have looked for tutorials on YouTube and all scripts bring errors.
Of course, if you just copypaste code from a tutorial without thinking then it will error. The code shown in tutorial is just an example and you’re supposed to write your own based on that.
If you put this in a part, it’ll print something if the player who touched it has a tool called “Keycard” held out.
function onTouched(hit)
local char = hit.Parent;
local hum = char:FindFirstChildOfClass("Humanoid"); --If a humanoid is present, a character touched it.
if hum then
local keycard = char:FindFirstChild("Keycard"); --Find a keycard
if keycard then --If a keycard was found...
print(char.Name .. " has a keycard!");
--do something
end
end
end
script.Parent.Touched:Connect(onTouched);