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

Why isn't this script doing anything?

Asked by 9 years ago

This script is supposed to check your mouse level, and depending on your mouse level change the chances of clicking on a rock, destroying it, and giving you 100 points. The problem is it isn't doing ANYTHING

plr = game.Players.LocalPlayer
points = plr:WaitForChild("Points")
mouse = plr:GetMouse()
keyName = 'GameRock'
chr = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()
lvl = script.Parent:WaitForChild("MouseLvl")
t = mouse.Target

if lvl.Value == 1 then
    mouse.Button1Down:connect(function()
        if t and t.Name == keyName then
            print 'targeted'
            local var1 = 1
            local var2 = math.random(1,10)--10%
            if var2 == var1 then
                print 'destroyed'
                t:Destroy()
                points.Value = points.Value + 100
            end
        end
    end)
elseif lvl.Value == 2 then
    mouse.Button1Down:connect(function()
        if t and t.Name == keyName then
        print 'targeted'
            local var1 = 1
            local var2 = math.random(1,5)--20%
            if var2 == var1 then
                print 'destroyed'
                t:Destroy()
                points.Value = points.Value + 100
            end
        end
    end)
elseif lvl.Value == 3 then
    mouse.Button1Down:connect(function()
        if t and t.Name == keyName then
            print 'targeted'
            local var1 = 1
            local var2 = math.random(1,2)--50%
            if var2 == var1 then
                print 'destroyed'
                t:Destroy()
                points.Value = points.Value + 100
            end
        end
    end)
elseif lvl.Value == 4 then
    if t and t.Name == keyName then
        t:Destroy()
        points.Value = points.Value + 100
    end
end
--Changed--
lvl.Changed:connect(function()
    if lvl.Value == 1 then
        mouse.Button1Down:connect(function()
            if t and t.Name == keyName then
                print 'targeted'
                local var1 = 1 --10%
                local var2 = math.random(1,10)
                if var2 == var1 then
                    print 'destroyed'
                    t:Destroy()
                    points.Value = points.Value + 100
                end
            end
        end)
    elseif lvl.Value == 2 then
        mouse.Button1Down:connect(function()
            if t and t.Name == keyName then
                print 'targeted'
                local var1 = 1--25%
                local var2 = math.random(1,5)
                if var2 == var1 then
                    print 'destroyed'
                    t:Destroy()
                    points.Value = points.Value + 100
                end
            end
        end)
    elseif lvl.Value == 3 then
        mouse.Button1Down:connect(function()
            if t and t.Name == keyName then
                print 'targeted'
                local var1 = 1 --50%
                local var2 = math.random(1,2)
                if var2 == var1 then
                    print 'destroyed'
                    t:Destroy()
                    points.Value = points.Value + 100
                end
            end
        end)
    elseif lvl.Value == 4 then
        if t and t.Name == keyName then
            t:Destroy()
            points.Value = points.Value + 100
        end
    end
end)

It's not printing 'targeted'it's not printing 'destroyed' either.

Answer this question