RemoteEvent not working?

I made a remote event so I can update a value on the server.

Scripts:

game.ReplicatedStorage.RequestDataUpdate:FireServer("AV",300,game.Players.LocalPlayer)
Remote.OnServerEvent:Connect(function(Type,Amount,Player)
    if Type == "AV" then
        Player.data.AV.Value = Amount
        print("Successfull AV")
    end
end)
1 Like

Does the error appears or it just a firing it does not happen?

game.ReplicatedStorage.RequestDataUpdate:FireServer("AV",300)
Remote.OnServerEvent:Connect(function(Player,Type,Amount) if Type == “AV” then Player.data.AV.Value = Amount print(“Successfull AV”) end end)

1 Like

When a client calls FireServer, the server fires OnServerEvent with the following values:

  1. The player whsoe client called FireServer
  2. Everything else that client provided to FireServer.

It looks like you’re trying to send the LocalPlayer - this isn’t necessary, as this information is always going to be available in the first parameter to OnServerEvent.

Edit: I also edited your post slightly to make the two scripts more apparent, by the way.

2 Likes
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players").LocalPlayer:WaitForChild("data")
local AVIntensity = Player.PlayerGui:WaitForChild("Menu"):WaitForChild("AVIntensity")
local Remote = ReplicatedStorage:WaitForChild("AVIntensitySave")

AVIntensity.Changed:Connect(function()
Remote:FireServer(AVIntensity.Value)
end)```

`local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remote = ReplicatedStorage:WaitForChild("AVIntensitySave")

Remote.OnServerEvent:Connect(function(Player,Value)
    Player:WaitForChild("data").AV.Value = Value
end)`

The script i just posted won’t work either… any suggestions?

(Assuming these were meant to be separate) These look OK. Maybe you should add a few calls to print to ensure your code is actually running.

Also, you should provide context to what you’re trying to accomplish. Is this a setting in a settings menu? Is it part of a tool? We can’t tell just from your provided code.

game.ReplicatedStorage.RequestDataUpdate:FireServer("AV",300)
Remote.OnServerEvent:Connect(function(Player,Type,Amount)

    if Type == "AV" then
        Player.data.AV.Value = Amount
        print("Successful AV")
    end

end)

this should work, otherwise please screenshot your output

--local script
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("RequestDataUpdate")

re:FireServer("AV", 300)
--server script
local rs = game:GetService("ReplicatedStorage")
local re = rs:WaitForChild("RequestDataUpdate")

re.OnServerEvent:Connect(function(Player, Type, Amount)
	if Type == "AV" then
		Player.data.AV.Value += Amount
		print("Successfull AV")
	end
end)

I assume you want to increase the stat’s value by 300 not set it to 300.

When calling FireServer() through a RemoteEvent instance from the client side within a local script the player object pertaining to the particular client which is firing the server is automatically passed as an argument to the callback function connected to the corresponding OnServerEvent event through the same RemoteEvent instance listening from the server side within a server script, as such all we need to do is declare an additional parameter to handle this received object on the server side, as the player object is the first value received the first parameter should represent that, additional parameters are then required to handle any optional arguments passed to FireServer() when it is called.

You never supply the AV value in the arguments, which is why it’s not working

remote:FireServer("AV", AVIntensity.Value)