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

attempt to index nil with 'Target' Bug. How do you fix?

Asked by 4 years ago

So basically I previously asked a question to do with Client to Client it has now been sort of fixed its just in the process a new bug has appeared the Output says : 11:40:45.214 - Players.EhEhEhEhLPKJ.PlayerGui.InventoryGUI.MainFrame.Slot1.Wood:9: attempt to index nil with 'Target'

And the code is :

local Slot1EventWood = game.ReplicatedStorage.Slot1Wood

Slot1EventWood.OnServerEvent:Connect(function(plr)

    local mouse = plr:GetMouse()

    repeat wait() until mouse.Target ~= nil

            local item = mouse.Target

            print("Client Received the Event")
               if script.Parent.QuantitiyVal == 1 then
               print("No room >:)")
                   if script.Parent.Item == "Wood" then
                     print("Room due to stacking")
                    elseif script.Parent.QuantitiyVal == 99 then
                        print("No room due to max stack limit")
                    end
                else
                    if item.Name == "Wood" then
                     item:Destroy()
                     end
               print("Room")
               script.Parent.Item.Value = "Wood"
               script.Parent.QuantitiyVal.Value = script.Parent.QuantitiyVal.Value + 1
               script.Parent.Visible = true
               script.Parent.Quantity.Text = script.Parent.QuantitiyVal.Value
    end
end)

There is a second script with the FireServer() function in it please say if you need it

Answer this question