Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The value sent through RemoteEvent is the tools name, but is somehow the players name?

This problem made the other person who tried to help me confused, including me.

I'm close to finishing this custom inventory, but this one and oddly confusing error just completely prevents me from completing this project. In line 2 of the Server Script, it prints out an error in the Output "BiIinear is not a valid member of Backpack" this is very confusing to me because the ItemNameValue, the value that is sent from Inventory Local Script to Server Script is the tools name, as determined from the Tool Local Script, is apparently the players name. I don't even know how it got this. I look on Client side, ItemNameValue is the tools name, and on Server side, the ItemNameValue is nil, this is obvious because this is inside a LocalPlayer, not even sure if I needed to add that bit. Here are the scripts.

Server Script:

game.ReplicatedStorage.EquipItem.OnServerEvent:Connect(function(player, item)
	player.Character.Humanoid:EquipTool(player.Backpack[item.Name])
end)

The variable of ItemNameValue is sent to the Server Script, so that way the script knows what to find. This is where the error occurs, on line 2.

Inventory Local Script:

wait(5)
local player = game.Players.LocalPlayer

--Equip
script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.ItemNameValue.Value ~= '' then
		if player.Character:FindFirstChild(script.Parent.ItemNameValue.Value) then
			print("Already equipped!")
		else
			local item = script.Parent.ItemNameValue.Value
			game.ReplicatedStorage.EquipItem:FireServer(player, item)
		end
	else
	end
end)

The Inventory Local Script sends the ItemNameValue to the Server Script. Not the actual value, just the values value, if that makes sense.

Tool Local Script:

local player = game.Players.LocalPlayer.PlayerGui.Inventory.Frame.SlotFrame

if player.Slot01.ItemNameValue.Value == 'nil' then
	player.Slot01.Image = script.Parent.TextureId
	player.Slot01.ItemNameValue.Value = script.Parent.Name
	player.Slot01:WaitForChild("DescriptionValue").Value = script.Parent:WaitForChild("DescriptionValue").Value
	player.Slot01.Active = true
	script:Destroy()
else
--This code block repeats 20 times, because there's 20 slots total in the inventory. No need to repeat it 20 times as the slot number adds up.

This all starts from clicking an item in workspace, the tool that has the same name as the item gets cloned from Lighting, and gets put into the players Backpack. The tools localscript is disabled, and configures an available slot, and the ItemNameValue.

I hope this makes sense to you, and I hope I get an answer from this, because this pretty much ruins my custom inventory if not solved, I'd have to rewrite every script. Thanks in advance.

1 answer

✓ Accepted answer

When you're on the client, never send the player as an argument because ROBLOX automatically does this for you. Technically player would be item for the server that's why it's broken.

Also you can't send the tools instance through a remote so try to send only the name

4 comments

0

The ItemNameValue's value is pretty much the only way I can send the tools name, in my view.

0

Oh then instead of doing Tool.Namr do just Tool

0

Wow, this actually worked. I tried this before, but that didn't work. I guess I got it a bit off. Thanks a bunch!

0

No problem, happy to help :)

This discussion is preserved as it was. New answers, comments, and votes are closed.