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

Why i can't send the information of equipped tool from Local Script to Server Script?

Im Trying to invoke Remote Function to send tool information when i equip the tool. On breakpoints, tool enters to variable but on server side, player's information sended always

local script on weapon


local tool = script.Parent


tool.Equipped:Connect(function()

	local weaponType = tool

	GetWeaponInformation:InvokeServer(weaponType)
	BindFireInput:Invoke()
	
end)

Server side script:

function getWeaponInformation(weaponInformation)
	print(weaponInformation)
	return  weaponInformation

end

GetWeaponInformation.OnServerInvoke = getWeaponInformation

2 answers

✓ Accepted answer

First of all, if you aren’t expecting a return in the client, then use a RemotEvent instead of a RemoteFunction. However, the issue here is remote events and functions on the server get an extra argument, which is the Player object of the client who fired it. So instead of your function arguments being getWeaponInformation(weaponInformation), they need to be getWeaponInformation(plr, weaponInformation). Don’t add the extra player argument to be fired from the clientside, only expect it on the server.

Reply with further questions, And please mark as correct if this solution worked for you!

1 comment

0

Thanks a lot!

When calling a RemoteFunction or RemoteEvent, the first argument on the server is the player who called it. So all you have to do is take account for that and everything else should work.

function getWeaponInformation(player,weaponInformation)

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