This is my first time using remote functions and I'm very confused. I'm trying to make a mod panel for my game in which you can set a player's speed.
My script:
local DSS = game:GetService("DataStoreService")
local SpeedStore = DSS:GetDataStore("SpeedStore")
game.ReplicatedStorage.ModPanelRemoteFunction.OnServerInvoke:Connect(function(sender, player, value, _type) -- Where the error is
if sender:GetRankInGroup(6323488) >= 2 then
if _type then
if _type == "Name" then
game.Players:FindFirstChild(player):WaitForChild("leaderstats"):WaitForChild("Speed").Value = value
return true
elseif _type == "Id" then
game.Players:GetPlayerByUserId(player):WaitForChild("leaderstats"):WaitForChild("Speed").Value = value
return true
end
elseif not _type then
local key = player
local data
local s, eM = pcall(function()
data = SpeedStore:GetAsync(key)
end)
if s and data then
local s2, eM2 = pcall(function()
SpeedStore:SetAsync(key, value)
end)
return true
elseif not data then
return false
end
end
else
sender:Kick("gg") -- Anti-Exploit
end
end)
My local script:
local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
local playerText = playerGui.ModPanel.MainFrame.NameOrUserId.Text
local newValue = playerGui.ModPanel.MainFrame.NewValue.Text
script.Parent.MouseButton1Click:Connect(function()
if game.Players:FindFirstChild(playerText) then
local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, "Name")
if not completed then
output(playerText.." is not a valid username.")
else
output("Sucessfully changed speed.")
end
local _, _ = pcall(function()
if game.Players:GetPlayerByUserId(playerText) then
local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, "Id")
if not completed then
output(playerText.." is not a valid User Id.")
else
output("Sucessfully changed speed.")
end
else
local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, nil)
if not completed then
output(playerText.." is not a valid User Id")
else
output("Sucessfully changed speed.")
end
end
end)
end
end)
function output(text)
if playerGui.ModPanel.OutputFrame.Visible == false then
playerGui.ModPanel.OutputFrame.Visible = true
playerGui.ModPanel.OutputFrame.TextLabel.Text = text
playerGui.ModPanel.OutputFrame:TweenPosition(
UDim2.new(0.338, 0,0.083, 0),
"Out",
"Elastic",
1)
else
playerGui.ModPanel.OutputFrame.TextLabel.Text = text
end
end
The output:
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
If you are able to help me I would greatly appreciate it.

8 comments
I think you need to remove _ from type at line 4
^ Okay, I'll try that.
Nope, not the problem.
Seems like you haven't invoked the remote function..
I have-
You don’t need to pass player. InvokeServer and FireServer automatically pass the player
No, that's not the case. I just looked at the Roblox developer page and it said it didn't.'
You still need player in the OnServerInvoke though