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

Help with end?

Asked by 10 years ago

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
Tabbing and spacing code properly is very very helpful. It helps you catch problems like this and read everything reasonably. BlueTaslem 18071 — 10y
0
*Edited because I found a new way but,I failed* kevinnight45 550 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

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.

Ad

Answer this question