I created a shovel that scoops dirt like in the game “The Underground War” but it suddenly stopped working. The scripts provided literally works but they just stoped. The raycastResult is printing as nil.
Client Script in the shovel.
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local debounce = false
script.Parent.Activated:Connect(function()
print("YES")
if not debounce then
debounce = true
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {script.Parent}
local raycastResult = workspace:Raycast(character:WaitForChild("HumanoidRootPart").CFrame.Position, character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 10, raycastParams)
warn(raycastResult)
if raycastResult then
local hit = raycastResult.Instance
local position = raycastResult.Position
script.Parent:WaitForChild("Dig"):FireServer(hit, position)
end
wait(0.5)
debounce = false
end
end)
Server Script inside the shovel
script.Parent:WaitForChild("Dig").OnServerEvent:Connect(function(player, hit, position)
print("FIRED")
if hit.Parent == workspace:WaitForChild("Dirt") then
print(hit.Transparency)
hit.Transparency += 0.25
if hit.Transparency > 0.75 then
hit:Destroy()
end
else
print("NOPE")
end
end)