when i click play it says "Touched is not a valid member of Model" can you help me
local checkpoint1 = game.Workspace.StartFinish local checkpoint2 = game.Workspace.Checkpoint1 local checkpoint3 = game.Workspace.Checkpoint2 local checkpoint4 = game.Workspace.Checkpoint3 function checkpoint1hit() print("Checkpoint1 was hit!") end checkpoint1.Touched:connect(checkpoint1hit)
checkpoint1
is, in fact, a Model
, otherwise the error would not have been generated.
The Touched
event is not defined for models, so you'll have to use the Touched
event of a Part
, probably a Part
inside your model.
You can't use a Touched
event on a model, it only works on a part.
To make this work, make a part in "StartFinish" called "Main" and after "StartFinish" on line 1, add ".Main" after.
local checkpoint1 = game.Workspace.StartFinish.Main --added here local checkpoint2 = game.Workspace.Checkpoint1 local checkpoint3 = game.Workspace.Checkpoint2 local checkpoint4 = game.Workspace.Checkpoint3 function checkpoint1hit() print("Checkpoint1 was hit!") end checkpoint1.Touched:connect(checkpoint1hit)