Event isn't workin in roblox

Clicks_Giver.Execute.MouseButton1Click:Connect(function()
		game.ReplicatedStorage.Cmds.cg:FireServer(Clicks_Giver.Player.Text	, Clicks_Giver.ClicksAmount.Text )	
end)

Thats the local script

game.ReplicatedStorage.Cmds.cg.OnServerEvent:Connect(function(E, amount)
	game.Players:FindFirstChild(E).leaderstats.Clicks.Value += tonumber(amount)
end)

and thats the script
So basically its not working when i type anyone’s name or even my username it doesnt give me clicks or anythin

Apparently, you have passed 2 arguments from the client. However, on the server, an extra argument of the Player is passed as well. So on the server, It should be:

game.ReplicatedStorage.Cmds.cg.OnServerEvent:Connect(function(Player, E, amount)

And then you can replace your argument of FindFirstChild in the next line with finding the player name:

game.Players:FindFirstChild(Player.Name).leaderstats.Clicks.Value += tonumber(amount)
2 Likes

the first parameter of a remote event will be the player that fired it.
DefaultBrain beat me to it lol.

2 Likes

When i type my name it adds value and when i type other ppl names that r in the servver it still adds the value to me not them

Can you show what amount of text you are sending from the client? Because, If It’s something like “999 coins”, converting to a number will return nil.
Also, send the error.

Its adding values to my list but not to others, even when i type their name

Can you show us how are you doing that? And show the output window as well.

Do you have discord so i can show u da whole thin

Clicks_Giver.Execute.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Cmds.cg:FireServer( Clicks_Giver.ClicksAmount.Text , Clicks_Giver.Player.Text)	
end)

local script ^^

game.ReplicatedStorage.Cmds.cg.OnServerEvent:Connect(function(Player, E, amount)
	game.Players:FindFirstChild(E.Name).leaderstats.Clicks.Value += tonumber(amount)
end)

^^^ SCRIPT

It’s not E.Name, your E argument is the Text you are sending (Your first argument)
It should be replaced with Player.Name, like I explained above

I tried Player.Name but it sttill doesnt work

02:12:29.554 ServerScriptService.Folder.Script:24: attempt to perform arithmetic (add) on number and nil - Server - Script:24

You still didn’t show the number argument that you are passing. That’s what causing the problem.