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

Filtering Enabled Pickaxe Doesn't Collect Gold?

Asked by 5 years ago

The pickaxe I'm working on is supposed to collect gold when the player clicks on the ore, which deletes the ore afterwards and adds money to the leaderboard. This script works in Studio, but not the actual game.

LocalScript inside the tool

local Tool = script.Parent

Tool.Activated:Connect(function()
    game.ReplicatedStorage.PickaxeHit:FireServer()
end)

Server Script inside the tool

game.ReplicatedStorage.PickaxeHit.OnServerEvent:Connect(function(player)

local Tool = player.StarterGear:FindFirstChild("GoldPickaxe")
local mouse = player:GetMouse();
local ting = 0


    if (mouse.Target.Parent.Name == "GoldOre") then
    mouse.Target:Destroy();

    local anim = Instance.new("StringValue")
    anim.Name = "toolanim"
    anim.Value = "Slash"
    anim.Parent = Tool

    if ting == 0 then 

        local user = player
        local stats = user:findFirstChild("leaderstats")

        if stats ~= nil then 
            local cash = stats:findFirstChild("Gold")
            cash.Value  = cash.Value  +1

        end
    end
end

end)
1
You shouldn't be getting the mouse on the server. User#19524 175 — 5y
1
You can't get mouse from the Server only localPlayer Sergiomontani10 236 — 5y

Answer this question