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

How to solve the store script problem? Hello everyone, I'm a beginner game developer

Asked by 3 years ago
Edited 3 years ago

recently started writing scripts and I got this error the script itself is here

PlayerGui.ShopGui.Frame.ScrollingFrame_12.ScrollingFrame.Arranger:9: attempt to index nil with 'IsA'

and script

game.ReplicatedStorage.GameClient.Events.RemoteEvent.PlayerLoaded:FireServer()
print("PlayerLoaded")
local player = game.Players.LocalPlayer
local number = 1
game.ReplicatedStorage.GameClient.Events.RemoteEvent.BeginArrangement.OnClientEvent:Connect(function()
    print("Got")
    repeat
        local image = game.ReplicatedStorage.ToolsImage:FindFirstChild(number)
        if image:IsA ("ImageLabel") then
            print(image.Name)
            local clone = game.ReplicatedStorage.Template:Clone()
            clone.ToolImageDisp.ImageLabel.Image = image.Image
            clone.Name = image.Name
            clone.CostDisplay.Value = image.Cost.Value
            clone.ToolName.Value = image.ToolName.Value
            clone.Parent = script.Parent
            clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(0,0,0) 

            if clone.Name == "1" then
                local sidemenu = script.Parent.Parent.Parent.SideMenu
                sidemenu.ImageOftool.Image = image.Image
                sidemenu.ImageOftool.ImageColor3 = Color3.fromRGB(255,255,255)
                sidemenu.BuyButton.TextButton.Text = "Equip"
                sidemenu.Cost.CostOfTool.Value = 0
                sidemenu.Cost.CostDisplayer.Text = "Cost : 0"
                sidemenu.NameOftool.TextLabel.Text = clone.ToolName.Value

            end

            if player.OwnedItems:FindFirstChild(clone.ToolName.Value) then
                clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(255,255,255)
            end

            local equipped = player:WaitForChild("Equipped")
            if equipped.Value~= nil then
                if clone.ToolName.Value == equipped.Value then
                    local sidemenu = script.Parent.Parent.Parent.SideMenu
                    sidemenu.ImageOftool.Image = image.Image
                    sidemenu.ImageOftool.ImageColor3 = Color3.fromRGB(255,255,255)
                    sidemenu.BuyButton.TextButton.Text = "Equipped"
                    sidemenu.Cost.CostOfTool.Value = clone.CostDisplay.Value
                    sidemenu.Cost.CostDisplayer.Text = "Cost : "..sidemenu.Cost.CostOfTool.Value
                    sidemenu.NameOftool.TextLabel.Text = clone.ToolName.Value
                    game.ReplicatedStorage.GameClient.Events.RemoteEvent.EquipTool:FireServer(equipped.Value)
                end
            end

            local number = tonumber(clone.Name)
            if number ~= 1 then
                local previousnum = number-1
                local itemfound = script.Parent:FindFirstChild(previousnum)
                if itemfound then
                    if player.OwnedItems:FindFirstChild(itemfound.ToolName.Value) then
                        clone.ToolImageDisp.ImageLabel.ImageColor3 = Color3.fromRGB(255,255,255) 
                    end 
                end
            end
        end
        number = number+1
    until number == game.ReplicatedStorage.TotalTools.Value + 1
end)

GUYS PLS HELP ME

0
You should check if the image actually exists Omq_ItzJasmin 666 — 3y

1 answer

Log in to vote
1
Answered by
SteamG00B 1633 Moderation Voter
3 years ago
Edited 3 years ago

When you get an error that says "attempt to index nil with ___" it means that whatever variable is on the left side of the operation is nil. So in this case, it is attempting to index image with IsA, but cannot do so because image is nil, and nil does not have the IsA operation.

So what you will want to do is trace back through your script to find out where you last set image, and figure out why whatever it is being set to is nil. In this case, when you set image to game.ReplicatedStorage.ToolsImage:FindFirstChild(number) I'm guessing you've made a typo in the path or number just doesn't exist at all.

To read errors in the future, just remember that the format of the error message is "script:line:error"

If this solves your answer then mark it as the accepted solution, if not, don't hesitate to ask me questions regarding this issue in the comments below my answer.

0
hello, thanks for your answer, read and a little information added to my head but what about the error ToolsImage is a file in which there should be object textures I have already checked 100 times what and where there may be an error, but I still haven't found how you say that number is not set but I assigned that local number = 1 and what about my typo it could be YTBrainBroYT 29 — 3y
0
oh really it was my typo thanks YTBrainBroYT 29 — 3y
0
Don't forget to mark this as the solution so people don't think it went unanswered. SteamG00B 1633 — 3y
Ad

Answer this question