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

LocalScript Issue, not a string?

Asked by
Bman8765 270 Moderation Voter
10 years ago

Okay so I have a localscript that is controlling a playergui (not finished but a start). Basically it has to arrow gui textbuttons and when you click them you should be able to freely move about the options it has to offer. Unfortunately this does not work if you have more than 2 options to view (options are hats)

You get this error if you try to do it:

16:31:35.591 - String expected
16:31:35.591 - Script 'Players.Player1.PlayerGui.MainScreen.Customizer.CustomizerF', Line 19 - global changeinfo
16:31:35.592 - Script 'Players.Player1.PlayerGui.MainScreen.Customizer.CustomizerF', Line 46
16:31:35.592 - Stack End
16:31:35.592 - Disconnected event because of exception

All variables are properly defined it is just an issue with something! Here is the script, if you could make this more efficient please do!

--------------------------------------------------------------------
-- Hat Table, add and remove as pleased
--------------------------------------------------------------------
hats = {"21243283", "184749513", "155654004", "55397193", "2336804"}
hatinfo = {"Some hat", "hat 2"}
hatimage = {"blah I need help", "right here"}
--------------------------------------------------------------------
-- Global Variables
--------------------------------------------------------------------
leftarrow = script.Parent.ArrowLeft
rightarrow = script.Parent.ArrowRight
currenthat = script.Parent.CurrentHat
hatimage = script.Parent.HatImage
page = 1
--------------------------------------------------------------------
-- Change Info Script
--------------------------------------------------------------------
function changeinfo()
    currenthat.Text = hatinfo[page]
    hatimage.Image = "http://www.roblox.com/Thumbs/Asset.ashx?Width=110&Height=110&AssetID=" .. hats[page]
    print(page)
end
changeinfo()
--------------------------------------------------------------------
-- Arrow Functions
--------------------------------------------------------------------
function ClickedLeft()
    if page >= #hats then
        page = 1
    elseif page <= #hats then
        if page ~= 1 then
            page = page -1
        elseif page == 1 then
            page = #hats
        end
    end
    changeinfo(page)
end

function ClickedRight()
    if page >= #hats then
        page = 1
    elseif page <= #hats then
        page = page +1
    end
    changeinfo(page)
end

leftarrow.MouseButton1Down:connect(ClickedLeft)
rightarrow.MouseButton1Down:connect(ClickedRight)

1 answer

Log in to vote
0
Answered by
Bman8765 270 Moderation Voter
10 years ago

Nvm I found a solution: The first few tables did not equal the top table so that's why

hats = {"21243283", "184749513", "155654004", "55397193", "2336804"}
hatinfo = {"Some hat", "hat 2", "hat 3", "hat 4", "hat 5"}
hatimage = {"blah I need help", "right here", "hello", "wassup", "hi"}
Ad

Answer this question