Remote function giving a weird error?
Asked by
4 years ago Edited 4 years ago
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:
01 | local DSS = game:GetService( "DataStoreService" ) |
02 | local SpeedStore = DSS:GetDataStore( "SpeedStore" ) |
04 | game.ReplicatedStorage.ModPanelRemoteFunction.OnServerInvoke:Connect( function (sender, player, value, _type) |
05 | if sender:GetRankInGroup( 6323488 ) > = 2 then |
07 | if _type = = "Name" then |
08 | game.Players:FindFirstChild(player):WaitForChild( "leaderstats" ):WaitForChild( "Speed" ).Value = value |
10 | elseif _type = = "Id" then |
11 | game.Players:GetPlayerByUserId(player):WaitForChild( "leaderstats" ):WaitForChild( "Speed" ).Value = value |
18 | local s, eM = pcall ( function () |
19 | data = SpeedStore:GetAsync(key) |
23 | local s 2 , eM 2 = pcall ( function () |
24 | SpeedStore:SetAsync(key, value) |
My local script:
01 | local playerGui = game.Players.LocalPlayer:WaitForChild( "PlayerGui" ) |
02 | local playerText = playerGui.ModPanel.MainFrame.NameOrUserId.Text |
03 | local newValue = playerGui.ModPanel.MainFrame.NewValue.Text |
05 | script.Parent.MouseButton 1 Click:Connect( function () |
06 | if game.Players:FindFirstChild(playerText) then |
07 | local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, "Name" ) |
09 | output(playerText.. " is not a valid username." ) |
11 | output( "Sucessfully changed speed." ) |
13 | local _, _ = pcall ( function () |
14 | if game.Players:GetPlayerByUserId(playerText) then |
15 | local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, "Id" ) |
17 | output(playerText.. " is not a valid User Id." ) |
19 | output( "Sucessfully changed speed." ) |
22 | local completed = game.ReplicatedStorage.ModPanelRemoteFunction:InvokeServer(game.Players.LocalPlayer, playerText, newValue, nil ) |
24 | output(playerText.. " is not a valid User Id" ) |
26 | output( "Sucessfully changed speed." ) |
34 | if playerGui.ModPanel.OutputFrame.Visible = = false then |
35 | playerGui.ModPanel.OutputFrame.Visible = true |
36 | playerGui.ModPanel.OutputFrame.TextLabel.Text = text |
38 | playerGui.ModPanel.OutputFrame:TweenPosition( |
39 | UDim 2. new( 0.338 , 0 , 0.083 , 0 ), |
44 | playerGui.ModPanel.OutputFrame.TextLabel.Text = text |
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.