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

invalid argument #2 (string expected, got Instance)?

I am using zblox's placement system v3. I have followed all the instructions, and this error has only started coming up very recently. (It was working before). Im not sure if im doing anything wrong? I also added some of my own stuff, as you can see. The errors are on lines

local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Error = script.Parent.Parent.Error

local GivenPlot = replicatedStorage.remotes.GivenPlot

local placing = false

local placementModule = require(replicatedStorage.Modules:WaitForChild("PlacementModule"))

local placement = placementModule.new(
	4,
	replicatedStorage.Models,
	Enum.KeyCode.R, Enum.KeyCode.X, Enum.KeyCode.U, Enum.KeyCode.L
)


local player = players.LocalPlayer
local mouse = player:GetMouse()
local plot

GivenPlot.OnClientEvent:Connect(function(pltnm)
	plot = pltnm
	print(plot)
end)



local remote = replicatedStorage.remotes:WaitForChild("place")

local Button = script.Parent.DC6.Click

local Button2 = script.Parent.DC5.Click

local Button3 = script.Parent.Royal.Click


Button.MouseButton1Click:Connect(function()
	Error.Visible = false
	if placing == false then
		placing = true
		placement:activate("DC6", workspace.Plots[plot].itemholder, workspace.Plots[plot], false, false)
	else
		Error.Visible = true
		wait(2)
		Error.Visible = false
	end
	
end)


Button2.MouseButton1Click:Connect(function()
	if placing == false then
		Error.Visible = false
		placing = true
		placement:activate("DC5", workspace.Plots[plot].itemholder, workspace.Plots[plot], false, false)
	else
		Error.Visible = true
		wait(2)
		Error.Visible = false
	end
	
end)


Button3.MouseButton1Click:Connect(function()
	if placing == false then
		Error.Visible = false
		placing = true
		placement:activate("Royal", workspace.Plots[plot].itemholder, workspace.Plots[plot], false, false)
	else
		Error.Visible = true
		wait(2)
		Error.Visible = false
	end
	
end)


mouse.Button1Down:Connect(function()
	placement:requestPlacement(remote)
end)

UIS.InputBegan:Connect(function(i,g)
	if i.UserInputType == Enum.UserInputType.Keyboard then
		if i.KeyCode == Enum.KeyCode.X then
			if placing == true then
				placing = false
			end
		end
	end

end)

The errors are on 43, 57 and 71, all the same errors. (invalid argument #2 (string expected, got Instance))

Like i said, it was working before, But now its not. Any help is appreciated :)

1 answer

If the itemholder object is a StringValue, use the .Value property. If it is not a StringValue, just use .Name.

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