remoteEvent (Local to Server)

OK so the issue is that the Event is inside a function that it is trying to call so it never runs the function
replace this

		sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
	end
end)

-- With
	end
    sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
end)
2 Likes

I did what you say but the problems its that now he cant find onSendPrimaryItemInfo

The reason why it is not working is because you never got the string value on the server.

you mean I never got the StringValue on the Client to the Server?

When you do OnServerEvent the arguments are always (PLAYER,ARGUMENT) So in your case you would need to do onPrimaryEquippedItem(player,PrimaryEquippedItem)

1 Like

Yes you sent in on client but never received it on server.

1 Like

Maybe try this

sendPrimaryItemInfo.OnServerEvent:Connect(onPrimaryEquipped(player, primaryEquippedItem)
1 Like

thats true let try it and come back

there you go the result

open.MouseButton1Click:Connect(function()
	
			print("Click")
			local remotes = game.ReplicatedStorage:WaitForChild("Remotes")
	local sendPrimaryItemInfo = remotes:WaitForChild("SendPrimaryItemInfo")
	
	function onPrimaryEquippedItem(PrimaryEquippedItem)
		print("got it")
			
			local primaryEquippedItem = PrimaryEquippedItem

		for _, v in pairs(workspace.ToolModels:GetChildren()) do
			if not v:IsA("Frame") then
				v:Destroy()
			end

		local handle = game.StarterGui:WaitForChild("Folder"):FindFirstChild(primaryEquippedItem.."Handle"):Clone()
		handle.Parent = workspace.ToolModels
		print("cloned")
			handle.Script.Disabled = false
		end

			sendPrimaryItemInfo.OnServerEvent:Connect(onPrimaryEquipped(player, primaryEquippedItem))
		end
	end)

What does the script say for the orange underline?

Sorry but from the looks of it you didn’t do what I said

open.MouseButton1Click:Connect(function()
	print("Click")
	local remotes = game.ReplicatedStorage:WaitForChild("Remotes")
	local sendPrimaryItemInfo = remotes:WaitForChild("SendPrimaryItemInfo")
	
	wait(.4)
	
    function onSendPrimaryItemInfo(PrimaryEquippedItem)
		print("got it")
	
		local primaryEquippedItem = PrimaryEquippedItem

		for _, v in pairs(workspace.ToolModels:GetChildren()) do
			if not v:IsA("Frame") then
				v:Destroy()
			end
		end

       local handle = game.StarterGui:WaitForChild("Folder"):FindFirstChild(primaryEquippedItem.Value.."Handle"):Clone()
	   handle.Parent = workspace.ToolModels
	   print("cloned")
	   handle.Script.Disabled = false
	end
    sendPrimaryItemInfo.OnServerEvent:Connect(onSendPrimaryItemInfo)
    -- You had a random end right here
end)

as @rottendogDkR said hover over the orange underline and tell us what it says

In the script fire to the client and inside of the client fire the event and technically you dont need an event since your detecting the click on server

you put:

-- onPrimaryEquipped instead of onPrimaryEquippedItem, which is the function's name

attempt to call a nil value - Server

Also maybe try putting player inside the function

just I think that I dont need to that Event think
I am going remove all and thanks all for your helps :+1: