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

Why would that be a syntax error?

Asked by 2 years ago
Edited 2 years ago
UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.A then
        Spawn1.Position = Vector3.new(50,50,50)

end)

Hello! Well, this error has happened many times and I still do not know why two things:

  1. Why is there a syntax error at the parenthesis of the final "end)"?
  2. Would the script work if the syntax error disappeared?

Thank you, I am still a beginner!

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)

Above is a function and needs an end with a parenthesis

 if input.KeyCode == Enum.KeyCode.A then

Above is a statement and requires an end

UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)
    if input.KeyCode == Enum.KeyCode.A then
        Spawn1.Position = Vector3.new(50,50,50)
    end
end)

You forgot the second end.

Ad

Answer this question