Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
4 years ago

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

Ad

Answer this question