Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why would that be a syntax error?

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.