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

Help with end?

How do I properly end line 27?

Output: line 27: unexpected symbol near ')'

---------------Vairbles---------------
local Tool = script.Parent
local Handle = script.Parent.Handle
local Player = game.Players.LocalPlayer--Gets LocalPlayer(which is the player with tool or script)
local PlayersMouse = Player:GetMouse()--Gets the Players mouse with the GetMouse() method
local Clicked = false
------------Coroutine.create---------------
ClickDectector = coroutine.create(function()
	 ---------Equiped Function----------
    	Tool.Equipped:connect(function(Mouse)
       	 Mouse.Button1Down:connect(function()
            Mouse.Move:connect(function()
            local Distance = (Mouse.Origin.p - Player.Character.Torso.Position).magnitude
                print("Distance From Player:"..Distance)
                Clicked = true
                if Distance > 21 
                    then
                    local Part = Instance.new("Part",game.workspace)
                        Part.CFrame = CFrame.new(Mouse.Origin.p)
                        Handle.BrickColor= BrickColor.new("Bright green")
                else
                    print("Nope,Nope,no bricks for you")
                    Distance = false
                    Handle.BrickColor = BrickColor.new("Bright red")

                	
				 	end)
                    end)
                    end)
                    end)
                    end
					end)

						coroutine.resume(ClickDectector)
                    ------Oh,it's been pressed again? lets end it-------
                            Mouse.Button1Down:connect(function()
                                Clicked = true
                            if Clicked == true 
                                then
                                print("Off")
                                    Handle.BrickColor = BrickColor.new("Meduim stone grey")
                                Clicked = false
									coroutine.yield(ClickDectector)
										else
											coroutine.resume(ClickDectector)
                                        end

2 comments

2

Tabbing and spacing code properly is very very helpful. It helps you catch problems like this and read everything reasonably.

0

Edited because I found a new way but,I failed

1 answer

✓ Accepted answer

dat indenting..

This might work: (haven't tested, give it a go)

---------------Vairbles---------------
local Tool = script.Parent
local Handle = script.Parent.Handle
local Player = game.Players.LocalPlayer--Gets LocalPlayer(which is the player with tool or script)
local PlayersMouse = Player:GetMouse()--Gets the Players mouse with the GetMouse() method
local Clicked = false
------------Coroutine.create---------------
ClickDectector = coroutine.create(function()
---------Equiped Function----------
    Tool.Equipped:connect(function(Mouse)
        Mouse.Button1Down:connect(function()
            Mouse.Move:connect(function()
                local Distance = (Mouse.Origin.p - Player.Character.Torso.Position).magnitude
                print("Distance From Player:"..Distance)
                Clicked = true
                if Distance > 21  then
                    local Part = Instance.new("Part",game.workspace)
                    Part.CFrame = CFrame.new(Mouse.Origin.p)
                    Handle.BrickColor= BrickColor.new("Bright green")
                else
                    print("Nope,Nope,no bricks for you")
                    Distance = false
                    Handle.BrickColor = BrickColor.new("Bright red")
                end
            end)
        end)
    end)
end)


coroutine.resume(ClickDectector)
------Oh,it's been pressed again? lets end it-------
Mouse.Button1Down:connect(function()
    Clicked = true
    if Clicked == true then
        print("Off")
        Handle.BrickColor = BrickColor.new("Meduim stone grey")
        Clicked = false
        coroutine.yield(ClickDectector)
    else
        coroutine.resume(ClickDectector)
    end
end)    

Most statements such as if, while, repeat and for are closed with the end statement, for example

if Clicked = true then
	print("Clicked!")
end

But there are some exceptions such as anonymous functions and coroutines but you shouldn't be using those unless you know how to close them properly.

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