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

Can somebody help me with my onButton1Down(mouse)?

Asked by
neoG457 315 Moderation Voter
9 years ago
function debounce(func)
    local isRunning = false    -- Create a local debounce variable
    return function(...)       -- Return a new function
        if not isRunning then
            isRunning = true

            func(...)          -- Call it with the original arguments

            isRunning = false
        end
    end
end

local player = game.Players.LocalPlayer

local Mouse = player:GetMouse()
        Mouse.KeyDown:connect(debounce(function(key)


    if key == "q" then 




        t = Instance.new("Part")        
        r = Instance.new("Part")
        x = Instance.new("Part")
        c = Instance.new("Part")
        e = Instance.new("Part")

        Player = script.Parent.Parent

        Instance.new ("SpecialMesh", x)
        x.Mesh.MeshId = "http://www.roblox.com/Asset/?id=9982590"

        Instance.new ("SpecialMesh", c)
        c.Mesh.MeshId = "http://www.roblox.com/Asset/?id=9982590"

        Instance.new ("SpecialMesh", e)
        e.Mesh.MeshId = "http://www.roblox.com/Asset/?id=9982590"

        Instance.new ("SpecialMesh", r)
        r.Mesh.MeshId = "http://www.roblox.com/Asset/?id=9982590"       

        Instance.new ("SpecialMesh", t)
        t.Mesh.MeshId = "http://www.roblox.com/Asset/?id=9982590"   

        c.Reflectance = 0.5
        c.Mesh.Scale = Vector3.new(0.5, 0.75, 0.5)
        c.BrickColor = BrickColor.new("Bright violet")
        c.TopSurface = "Smooth"
        c.BottomSurface = "Smooth"
        c.Name = Player.Name
        c.Anchored = false
        c.CanCollide = false 
        c.Transparency = 0
        c.Parent = workspace
        c.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)




        x.Reflectance = 0.5
        x.Mesh.Scale = Vector3.new(0.5, 0.75, 0.5)
        x.BrickColor = BrickColor.new("Bright violet")
        x.TopSurface = "Smooth"
        x.BottomSurface = "Smooth"
        x.Name = Player.Name
        x.Anchored = false
        x.CanCollide = false 
        x.Transparency = 0
        x.Parent = workspace
        x.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)

        e.Reflectance = 0.5
        e.Mesh.Scale = Vector3.new(0.5, 0.75, 0.5)
        e.BrickColor = BrickColor.new("Bright violet")
        e.TopSurface = "Smooth"
        e.BottomSurface = "Smooth"
        e.Name = Player.Name
        e.Anchored = false
        e.CanCollide = false 
        e.Transparency = 0
        e.Parent = workspace
        e.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)

        r.Reflectance = 0.5
        r.Mesh.Scale = Vector3.new(0.5, 0.75, 0.5)
        r.BrickColor = BrickColor.new("Bright violet")
        r.TopSurface = "Smooth"
        r.BottomSurface = "Smooth"
        r.Name = Player.Name
        r.Anchored = false
        r.CanCollide = false 
        r.Transparency = 0
        r.Parent = workspace
        r.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)

        t.Reflectance = 0.5
        t.Mesh.Scale = Vector3.new(0.5, 0.75, 0.5)
        t.BrickColor = BrickColor.new("Bright violet")
        t.TopSurface = "Smooth"
        t.BottomSurface = "Smooth"
        t.Name = Player.Name
        t.Anchored = false
        t.CanCollide = false 
        t.Transparency = 0
        t.Parent = workspace
        t.CFrame = Player.Character.Torso.CFrame*CFrame.new(0, 0, 0)


        w = Instance.new('Weld')
        w.Part0 = x
        w.Part1 = Player.Character.Torso
        w.Parent = x
        w.C1 = CFrame.Angles(20, 0, 0)*CFrame.new(0, 2, 0)


        w1 = Instance.new('Weld')
        w1.Part0 = c
        w1.Part1 = Player.Character.Torso
        w1.Parent = c
        w1.C1 = CFrame.Angles(25, 0, 0)*CFrame.new(0, 1.80, 3)

        w2 = Instance.new('Weld')
        w2.Part0 = e
        w2.Part1 = Player.Character.Torso
        w2.Parent = e
        w2.C1 = CFrame.Angles(18, 0, 0)*CFrame.new(0, 1.5, 4.5)

        w3 = Instance.new('Weld')
        w3.Part0 = r
        w3.Part1 = Player.Character.Torso
        w3.Parent = r
        w3.C1 = CFrame.Angles(17, 0, 0)*CFrame.new(0, -1, 4.5)

        w4 = Instance.new('Weld')
        w4.Part0 = t
        w4.Part1 = Player.Character.Torso
        w4.Parent = t
        w4.C1 = CFrame.Angles(16, 0, 0)*CFrame.new(0, -3.25, 3)




        end
            end))   

local Mouse = player:GetMouse() 

    function onButton1Down(mouse)   


    local po = game.Players.LocalPlayer


local Spiral = Instance.new("Animation")
    Spiral.AnimationId = "http://www.roblox.com/Asset?ID=227009893"
local animTrack = po.Character.Humanoid:LoadAnimation(Spiral)
        animTrack:Play()

    local function onSelected(mouse)
    Mouse.Button1Down:connect(function() onButton1Down(mouse) end)

Mouse.Button1Down:connect(function()

    end)
        end
            end

I want to be able to click and play the animation only after "q" is pressed, Sorry but there may be something wrong with my Button1Down function, I cant tell.

0
Your actual Button1Down event contains no code(lines 165 - 167). Goulstem 8144 — 9y
0
What's wrong is you're trying to make us fix a 169 line script. I'll help you anyway... yumtaste 476 — 9y

1 answer

Log in to vote
1
Answered by
Tkdriverx 514 Moderation Voter
9 years ago

There are a couple problems.

  1. The actual connection of the Button1Down is inside a function that doesn't get called.
  2. There is no need for the local function onSelected at all.
  3. You get the player's mouse twice. You only need to do that once.
  4. Your code was originally optimized for a tool or hopperbin. You need to recode a lot of it to get it to work with PlayerMouse.

We aren't going to completely rewrite your code for you.

Ad

Answer this question