Why is MouseButton1Down malfunctioning?
I have a localscript that is in a TextButton. When i click anywhere , the effect is the same to clicking the button. Why does this happen? How can i fix it?script:
02 | function onMouseButton 1 Down() |
05 | local sp = script.Parent |
06 | sp.MouseButton 1 Down:Connect(onMouseButton 1 Down()) |
07 | repeat wait( 0.1 ) until ready = = true |
10 | local clone = game:GetService( "ReplicatedStorage" ).Plane:Clone() |
11 | local mouse = game.Players.LocalPlayer:GetMouse() |
12 | local firstclick = false |
13 | clone.Parent = workspace |
14 | function invisible(model,scale) |
15 | local c = model:GetChildren() |
17 | if c [ i ] .className ~ = "Model" then |
18 | c [ i ] .Transparency = scale |
24 | function anchor(model,bool) |
25 | local c = model:GetChildren() |
27 | if c [ i ] .className = = "Model" or c [ i ] .className = = "Folder" then |
34 | function collide(model,bool) |
35 | local c = model:GetChildren() |
37 | if c [ i ] .className = = "Model" or c [ i ] .className = = "Folder" then |
40 | c [ i ] .CanCollide = bool |
47 | mouse.Button 1 Down:connect( function () |
48 | if firstclick = = false then |
53 | while click = = true do |
54 | clone:MoveTo(mouse.Hit.Position) |
59 | mouse.Button 1 Up:connect( function () |
60 | if click ~ = false then |
66 | clone.VehicleSeat.Main.Disabled = false |