I have made a shovel tool that digs terrain and reveals crates hidden underground. For some reason, only in the live game, mysterious barriers seem to block the player from moving after they remove dirt, and get stuck as a result. I have no idea what’s causing this problem, and it only seems to get stranger the more I test it.
Here’s a video of the problem:
And here’s what I thought would be the be-all-end-all of tests on this which I ran in the dev console:
And the even weirder result that doesn’t seem to make any sense whatsoever:
As you can see the part ended up not directly under me, but a ways away from me as if I had actually fallen into the hole.
I don’t know if this is an engine bug or not, but I have thoroughly looked over my code for the tool, and I haven’t found anything that could cause this behavior. For reference here is the code for the shovel, if you can find the issue it would be greatly appreciated.
in localscript:
local ReplicatedStorage= game:GetService("ReplicatedStorage")
local AudioPlayerModule = require(ReplicatedStorage:WaitForChild("AudioPlayer"))
AudioPlayerModule.preloadAudio({
["Dig"] = 4925590698
})
local rand = Random.new()
script.Parent.Activated:Connect(function()
if game.Players.LocalPlayer.Character.Head.Position.Y < game.Workspace.Baseplate.Baseplate.Position.Y then
AudioPlayerModule.playAudio("Dig",1,false)
end
end)
script.Parent.Deactivated:Connect(function()
local hum = game.Players.LocalPlayer.Character.Humanoid
local target = hum.TargetPoint
local crate = script.Parent.RemoteFunction:InvokeServer(target)
for i,v in pairs(crate) do
v.Transparency = 0
for x,y in pairs(v:GetChildren()) do
if y:IsA("SurfaceGui") then
y.Enabled = true
end
end
end
end)
script.Parent.Equipped:Connect(function()
game.Lighting.GlobalShadows = false
game.Players.LocalPlayer.CameraMinZoomDistance = 10
end)
script.Parent.Unequipped:Connect(function()
if game.Players.LocalPlayer.Character.Head.Position.Y > game.Workspace.Baseplate.Baseplate.Position.Y then
game.Lighting.GlobalShadows = true
game.Players.LocalPlayer.CameraMinZoomDistance = 0
end
end)
In regular script:
local flag = false
--remove terrain
function dig(player, part)
if flag == false then
flag = true
if player.Character.Head.Position.Y > workspace.Baseplate.Baseplate.Position.Y then
game.Workspace.Terrain:FillBlock(CFrame.new(part.Position)*CFrame.new(0,-10,0),part.Size,Enum.Material.Air) -- fixes buggy digging at entrance
else
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10
game.Workspace.Terrain:FillBlock(CFrame.new(part.Position),part.Size,Enum.Material.Air)
end
wait(0.095)
flag = false
end
end
function script.Parent.RemoteFunction.OnServerInvoke(player,target)
local part = Instance.new("Part")
part.Transparency = 1
part.Anchored = true
part.CanCollide = false
part.Position = target
part.Size = Vector3.new(10,10,10)
part.Parent = workspace
local Track = player.Character.Humanoid:LoadAnimation(script.Parent.R15Slash)
Track:Play(0)
local digs = coroutine.create(dig)
coroutine.resume(digs,player,part)
local crates = {}
--Make a list of all hidden crates found
for i,v in pairs(part:GetTouchingParts()) do
if v:FindFirstChild("giveMoney") then
table.insert(crates,#crates+1,v)
end
end
part:Destroy()
return crates
end