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
1local part = game.Workspace.Part
2 
3if part.Touched:Connect(function() then
4    print("Hello")
5    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
1if part.Touched:Connect(function() then

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

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

Answer this question