im trying to make an inventory that has a button that will allow you to drop the tool you have selected. im almost done but the way im trying to do this isn't working. here's the scripts

local:

local selected = script.Parent.Parent.Parent.Handler.Selected
local player = game.Players.LocalPlayer
local character = player.Character
local service = game:GetService("ReplicatedStorage")
local event = service.DropThing

function fire()
	if selected.Value ~= nil then
		local value = selected.Value
		event:FireServer(value)
		selected.Value = nil -- this isn't why, i tried without this line just in case
		character.Humanoid:UnequipTools()
	end
end

script.Parent.MouseButton1Click:Connect(fire)

as you can see above, im trying to pass the value that's in the "selected" String value

server:

local service = game:GetService("ReplicatedStorage")
local event = service.DropThing

local tools = workspace.tools

function drop(player,value)
	local hrp = player.Character:FindFirstChild("HumanoidRootPart")
	local drop = tools[value]:Clone() --error
end

event.OnServerEvent:Connect(drop)
--not full code but that's all you really need to see

however, whenever i fire the event, i get the error: invalid argument #2 (string expected,got nil)

I know what that means, but idk why im getting it; i am passing a string

anyway, if anyone could tell me how i could fix this that would be appreciated

4 comments

0

Ah I think I've got this one you see the event your not receiving the player. Done this many times it should be event.OnServerEvent:Connect(plr, drop) i think because when a remote event is sent it sends the plr. Let me know if this works.

0

dont work f

0

yeah it is

0

Try Doing