Hi everyone! I’m trying to make a touch event that runs a script when… uh… touched.
But for some reason, the script is running itself, even if I didn’t touch the part.
Here’s the script:
part = workspace.RandomFolder.Part
local debounce = false
local function onTouch()
if debounce then return end
debounce = true
--Code
end
part.Touched:Connect(onTouch)
I’ve already tried using only function onTouch() but it didn’t worked.
touch triggers whenever anything touches the part thats why u should check for a specific part like the character to touch that part if that makes sense
local TouchPart = game:GetService("Workspace").CurrentMission.StartWilburDialogue
local function onTouch()
--Code
end
TouchPart.Touched:Connect(onTouch)
-- this is only example code
local TouchPart = game:GetService("Workspace").CurrentMission.StartWilburDialogue
local function onTouch(hit)--detects whatever part touches the part
if hit.Name == "LeftFoot" then-- will only go trough if the part that hit the part has the correct name
-- enter code
end
TouchPart.Touched:Connect(onTouch)