Hello, I come here once again for the help! I'm currently learning how to use the tagged plugin and I come across the error " Touched is not a valid member of Script". I know it has something to do with the tagged plugin and i am requesting the help of a more experienced developer! Thank you!
Code in question:
local CollectionService = game:GetService("CollectionService")
local teleport = CollectionService:GetTagged("Tel")
local tele1 = game.Workspace.telePads.telePad1
local tele2 = game.Workspace.telePads.telePad2
local db = true
for _, tp in pairs(teleport)do
tp.Touched:Connect(function(hit)
Full Code:
local CollectionService = game:GetService("CollectionService")
local teleport = CollectionService:GetTagged("Tel")
local tele1 = game.Workspace.telePads.telePad1
local tele2 = game.Workspace.telePads.telePad2
local db = true
for _, tp in pairs(teleport)do
tp.Touched:Connect(function(hit)
local char = hit.Parent
local hum = char:FindFirstChild("Humanoid")
if hum and db then
if tp.Name == "telePad1" then
db = false
-- send player to tele2
char.HumanoidRootPart.CFrame = tele2.CFrame + Vector3.new(0,5,0)
wait(3)
db = true
else
if tp.Name == "telePad2" then
db = false
-- send player to tele1
char.HumanoidRootPart.CFrame = tele1.CFrame + Vector3.new(0,5,0)
wait(3)
db = true
end
end
end
end)
end

1 comment
well "tp" obviously has to be a script , so why is there a touched event created for "tp"?