Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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!

0
Thanks a lot! emay0660 13 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

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)

Answer this question