Im testing a way to send items to my inventory so i make a dummy npc with a clickdectector and a simple chat gui with a confirm button that should send a remote event with parameters (player, the item from a table of items, and the amount from a var)
the local script seems to be working i think since all the prints will print out but maybe all the info isn't being sent and the listener part of remote event isnt getting all the information. None of the tests prints from replicatedstorage script is printing. i have never used multiple parameters on a remote event before. I included both sets of scripts.
local script
local ReplicatedStorage = game:GetService("ReplicatedStorage") local send = ReplicatedStorage.GivePlr:WaitForChild("RemoteEvent") local Players = game:GetService("Players") local player = Players.LocalPlayer local num = false local Clicked = game.Workspace.Noob.ClickDetector local Clicked1 = script.parent.Frame.Confirm local itemgive = ReplicatedStorage.cards[" FireBall "] --not sure if this is correct way to pull from table local amount1 = 1 local function chat1() -- text of noob npc if num == true then script.Parent.TextLabel.Visible = true script.parent.TextLabel.Text = "Hi, would you like a free card" wait(2) print("chat ran") script.Parent.TextButton.Visible = true num = false end end function onMouseClick() --if noob npc clicked, then run this print("Clicked noob") if script.parent.Frame.Visible == true then else if script.parent.Frame.Visible == false then script.parent.Frame.Visible = true print("turned chat on") chat1() end end end Clicked.MouseClick:Connect(onMouseClick) --checking if noob is clicked Clicked1.MouseButton1Click:Connect(function() --gui button being clicked send:FireServer(itemgive, amount1) --sending event with a item and a int number print("sent file") end)
script on replicated storage
local ReplicatedStorage = game:GetService("ReplicatedStorage") local GivePlayerEvent = ReplicatedStorage:WaitForChild("GivePlr") local gameitems = ReplicatedStorage:WaitForChild("cards"):GetChildren() GivePlayerEvent.RemoteEvent.OnServerEvent:Connect(function(plr, itemgive, amount1) print("print 1") local inv = plr.StarterGui.InvGui.Inv local id1 = 0 for i, v in pairs(gameitems) do --check all items print("print 2") if v.Name == itemgive.Name then --checks if item is same id1 = itemgive.id.Value print("print 3") break end end for i, v in pairs(inv) do --checking if item is already in inventory print("print 4") if v.amount.Value >= 1 then v.amount.Value = amount1 + v.amount.Value --adding amounts together in inventory print("got event3") print("print 5") break else if v.amount.Value == 0 then --if its new item going into inventory v.amount.Value = amount1 v.pic.Image = id1 print("print 6") break end end end end)
I have been getting weird readouts from the output but i dont understand what the cloud comments are, even when i run studio with no scripts i keep getting some cloud errors.
10:31:20.796 cloud_142731176._Char:15: attempt to index nil with 'Name' - Server 10:31:22.160 cloud_142731176._Char:365: attempt to index nil with 'GetChildren' - Client 10:31:23.523 cloud_142731176._Char:93: attempt to index nil with 'Head' - Client 10:31:23.672 cloud_142731176._Char:93: attempt to index nil with 'Head'