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

How to get this script to run code when Mouse.Button1Down and Mining == true?

Asked by 7 years ago
Edited 7 years ago

I am making a mining script and it is supposed to run when the player presses Button1, but nothing happens. Here is the script:

--LocalScript
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local Mining = false
local Strength = player.Strength
function Xplo()
    Mouse.Target.Xplo.Enabled = true
    wait(0.1)
    Mouse.Target.Xplo.Enabled = false
end

Mouse.Button1Down:connect(function()
    Mining = true
    while true do
        wait(0.1)
        if Mining == true then
            Mouse.Target.Durability.Value = Mouse.Target.Durability.Value - Strength
            Mouse.Target.Break.Durabilty.Visible = true
            if Mouse.Target.Durability.Value <= 0 then
                local Dropz = Mouse.Target.Drop.Value
                Mouse.Target.BottomImage:Destroy()
                Mouse.Target.FrontImage:Destroy()
                Mouse.Target.BackImage:Destroy()
                Mouse.Target.LeftImage:Destroy()
                Mouse.Target.RightImage:Destroy()
                Mouse.Target.TopImage:Destroy()
                Mouse.Target.Transparency = 1
                Xplo()
                local Item = game.ServerStorage.Dropz:Clone()
                local pos = Mouse.Target.Position
                Item.Position = Vector3.new(pos)
                Mouse.Target:Destroy()
            end
        end
    end
end)

Mouse.Button1Up:connect(function()
    Mining = false
    Mouse.Target.Durability.Value = Mouse.Target.FirstDura.Value
    Mouse.Target.Break.Durabilty.Visible = false
end)
0
Are there any errors when you play the game in Roblox Studio? cfiredog 274 — 7y
0
You don't know what `Mouse.Target` is yet! Check it prior to attempting to manipulate it. Goulstem 8144 — 7y
0
No errors. Have you also read the wiki about Mouse.Target? It is the object the mouse is pointing to. I am pointing to a part that has every single one of these things. TinyScripter 70 — 7y
0
I dont get what you mean and what the point of the script does VenomiZeD_VamqireXz 111 — 7y
0
So then your not a scripter TinyScripter 70 — 7y

Answer this question