Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I got a syntax error but I do not know what have I done wrong?

Asked by 3 years ago
local part = game.Workspace.Part

if part.Touched:Connect(function() then
    print("Hello")
    end) 

syntax error please help me fix

2
delete if and then WINDOWS10XPRO 438 — 3y
0
You need to understand how events work https://developer.roblox.com/en-us/articles/events MarkedTomato 810 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
if part.Touched:Connect(function() then

that's the error: you used 'if then' and ':connect()' in eachother. events work like this:

Instance.Event:connect(function(inputsIfAnyAreNeeded,input2IfNeeded)
    -- code
end)
Ad

Answer this question