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

why remotes's values are not being correctly grabbed?

Asked by 5 years ago

So i have a local script that fires a remote, the remote is being fired, but the value with it is not correct, instead of printing the desired value on the local, it's printing the player's name, there are the scripts related to that function:

Server

remote = script.Parent.ValueStorage:WaitForChild("SwitchModes")

remote.OnServerEvent:Connect(function(currentmode)
    print(currentmode)
end)

Local (not full script)

currentmode = "Stun" -- all functions related to the value that's supposed to be sent to server.
script.Parent.ValueStorage.SwitchModes:FireServer(currentmode)

I suppose that the remote is printing the value that already comes with the remote, when its fired, the player, but its printing the name and not the player model, so i really don't know what exactly is going on. help would be appreciated...

1 answer

Log in to vote
1
Answered by
Fad99 286 Moderation Voter
5 years ago

When Fireing from Client to Server the first argument will always be the player that fired it, then whatever you passed. so in the server script it should be

remote = script.Parent.ValueStorage:WaitForChild("SwitchModes")

remote.OnServerEvent:Connect(function(Player,currentmode)
    print(currentmode)
end)
0
Thank you! Igoralexeymarengobr 365 — 5y
0
np Fad99 286 — 5y
0
Hey, i have another problem, at first i thought it worked, but it seems like to be the same, what variable did you use for Player, i did game:GetService("Players").LocalPlayer, but it still prints the player name and not currentmode's value, currentmode value is definitively not the player name... Igoralexeymarengobr 365 — 5y
0
you wont need a variable to pass as the player, it will automatically find which players local script fired the server and define it for you Fad99 286 — 5y
View all comments (2 more)
0
This video script guider made helped me out a ton: https://www.youtube.com/watch?v=4Dc_bri9mjs if you have further questions just feel free to ask Fad99 286 — 5y
1
lol i found out that i inserted the variables wrong in function :v all working Igoralexeymarengobr 365 — 5y
Ad

Answer this question