I am trying to make a function to check if the player is touching a part. The part is chosen through a variable which looks at a players checkpoint value. So if I am at checkpoint 1, it will look for the part with the number 1 as its name within a certain folder. I am trying to make it so if they are at the checkpoint, they can not use a button which teleports them back to their current stage for fairness issues. I know in my script (below) I use GetTouchingParts but I tried putting my part CanCollide to true but it still did not work so I have a touched event for a touch interest. Overall, it is not working. I got this error.
local check = workspace.CheckParts local player = game.Players.LocalPlayer local stage = player.leaderstats.Stage local Part =check[stage.Value] local CurrentStage = game.StarterGui.MainGui.Teleporters.Frame["Current Stage"] Part.Touched:Connect(function() end) function CheckIfPlayerIsInArea(Part,Character) local touching = Part:GetTouchingParts() for i=1,#touching do if touching[i] == Character.HumanoidRootPart then print("worked") CurrentStage.Visible = false return true end end return false end CheckIfPlayerIsInArea()