Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Pickaxe script is not working? How do I fix my malfunctioning script?

Hi, I've started to make a simple mining game focused to help my lua skills and scripting knowledge, first of all it is erroring. It says this: "11:50:15.286 - ServerScriptService.Script:2: bad argument #2 to '?' (string expected, got Object)"

If you can help me out, I'd really appreciate it.

Pickaxe Script

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

script.Parent.Activated:Connect(function(plr)
	local  A1 = mouse.Target
	game.ReplicatedStorage.Dig:InvokeServer(A1)
end)

ServerScriptService

game.ReplicatedStorage.Dig.OnServerInvoke = function(A1)
workspace[A1]:Destroy()
end

1 answer

✓ Accepted answer

A1 is an object, so you don't need to use workspace[A1] to get the object.

Here's a fixed ServerScriptService script:

game.ReplicatedStorage.Dig.OnServerInvoke = function(A1)
	A1:Destroy()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.