Values on OnServerEvent

Hello developers!
I calls a server event with two values!
I don’t know how to say i just attach scripts

Local Script:

script.Parent.MouseButton1Click:Connect(function()
	local replic = game:GetService("ReplicatedStorage").Events
	local player = game:GetService("Players").LocalPlayer

	local value = player.Upgrades.upClick.Value + 100000 * 2

	print(value)
	replic.UpgradeClicks:FireServer(player.Name, value) -- 1: player, 2: cost.
end)

Script:

local replic = game:GetService("ReplicatedStorage").Events

replic.UpgradeClicks.OnServerEvent:Connect(function(player, cost)
	print(player) -- 200001
	
	wait(10)

	print(cost) -- ScaryLedP

	--[[if player.leaderstat.Points.Value > cost or player.leaderstat.Points.Value == cost then
	
		player.Upgrades.upClick.Value += 1
	
		--print(cost)

		player.leaderstat.Points.Value -= cost
	else 
		return warn("unsuccessfull")
	end
	--]]
end)

:tired_face:

What you did wrong here is that when calling FireServer from a LocalScript, it will add an extra Player argument before all the others. You can remove that player.Name from your LocalScript and it should work fine.

1 Like

This is in the wrong category
#help-and-feedback:scripting-support

3 Likes