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

Script Detects StringValue as a Table. Why and how do i fix it?

Asked by 5 years ago

I have a AutoShutdownScript on my game that was not made by me and it has an error. A value is detected as a table, not a string value as it is supposed to be.

if placeId == 0 then script:Destroy() end -- No proper info.
local market = game:WaitForChild("MarketplaceService")
local serverVersion = Instance.new("StringValue",game) --This is the StringValue that is detected as a table

serverVersion.Value = market:GetProductInfo(placeId) --This line is where it errors
serverVersion.Name = "SERVER_VERSION"

while true do --Extra code in the script if you want to see it
    game:GetService("RunService").Stepped:wait()
    local currentVersion = market:GetProductInfo(placeId)
    if currentVersion ~= serverVersion.Value then
        if manualShutDown ~= true then
            local m = Instance.new("Message",workspace)
            m.Text = "This game has been updated! Shutting down server..."
            wait(1)
            Instance.new("ManualSurfaceJointInstance",workspace)
        else
            local f,s = string.find(currentVersion,"autoshutdown:go")
            if f ~= nil and s ~= nil then
                local m = Instance.new("Message",workspace)
                m.Text = "This game has been updated! Shutting down server..."
                wait(1)
                Instance.new("ManualSurfaceJointInstance",workspace)
            end
        end
    end
end                                                                                                                         

Please Help

1 answer

Log in to vote
0
Answered by
Gojinhan 353 Moderation Voter
5 years ago

The issue is that you're trying to set a string value to a table value.

serverVersion.Value -- a string = market:GetProductInfo(placeId)  --- get product info returns a table for a place Id 

I'm not proficient with tables enough to show you how to do it, but you could try a for loop that index through that table and then use the value inside that table to assign to your string value

Sorry if that didn't make any sense

Ad

Answer this question