Hello, today I stumbled across an error in my script
The script should make the player be able to mine a rock…
Client-Side Script
local Mouse = game.Players.LocalPlayer:GetMouse()
local Obj = game.Workspace.Objects
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("SoundService")
local Remotes = RS.Remotes
local Pickaxe = script.Parent
local db = false
local activeAnim = nil
Pickaxe.Equipped:Connect(function()
local Humanoid = Pickaxe.Parent:WaitForChild("Humanoid")
local IdleAnim = Pickaxe.Animations:WaitForChild("Idle")
local track = Humanoid:LoadAnimation(IdleAnim)
track:Play()
activeAnim = track
end)
Pickaxe.Unequipped:Connect(function()
if activeAnim then
activeAnim:Stop()
activeAnim = nil
end
end)
Pickaxe.Activated:Connect(function(plr)
if db then
return
end
db = true
Remotes.ToolActivated:FireServer(Mouse)
wait(1)
db = false
end)
Server-Side Script
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("SoundService")
local Remotes = RS:WaitForChild("Remotes")
local Sound = SS:WaitForChild("PickaxeHit")
local Obj = workspace:WaitForChild("Objects")
Remotes.ToolActivated.OnServerEvent:Connect(function(plr, Mouse)
local Pickaxe = plr.Character.Pickaxe
local RockValue = plr.leaderstats.Rocks
local Humanoid = Pickaxe.Parent:WaitForChild("Humanoid")
local ActivateAnim = Pickaxe.Animations:WaitForChild("Click")
local track = Humanoid:LoadAnimation(ActivateAnim)
local SoundClone = Sound:Clone()
SoundClone.Parent = Pickaxe
if Mouse.Target.Parent == Obj.Rocks then
SoundClone:Play()
track:Play()
if Mouse.Target.Damage.Value == 0 then
Mouse.Target:Destroy()
else
Mouse.Target.Damage.Value = Mouse.Target.Damage.Value - 1
RockValue.Value = RockValue.Value + 1
Mouse.Target.Size = Mouse.Target.Size / 1.1
Mouse.Target.Position = Vector3.new(Mouse.Target.Position.X, Mouse.Target.Size.Y / 1.1, Mouse.Target.Position.Z)
wait(1)
SoundClone:Destroy()
end
end
end)
Photo with the error: