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
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.