Gui value adding depends on how many people are in the game

ive made a system of where a proximity prompt is triggered, it fires the client which fires another server script. It works perfectly if there is 1 person in the game adding 10 at a time, however if there are 2 players it will add 20%, etc

local ScreenGui = script.Parent
local text = ScreenGui.Frame.text
local frame = script.Parent.Frame
local up = game.SoundService.up
game.ReplicatedStorage.Remotes.ups.OnServerEvent:Connect(function(player)
	game.ReplicatedStorage.Remotes.sw:FireClient(player)
	game.ReplicatedStorage.Remotes.Connect.OnServerEvent:Connect(function()
		text.nu.Value = text.nu.Value + 10
		wait()
		text.Text = text.nu.Value

That’s because you are creating a new event connection every time a player fires the ups remote.

so what would i do to fix that?

I’m not entirely sure what your code is trying to do. If the .Connect remote is just going to increase the number when fired then it should be connected only once just like the ups remote

game.ReplicatedStorage.Remotes.ups.OnServerEvent:Connect(function(player)
	game.ReplicatedStorage.Remotes.sw:FireClient(player)
end)
game.ReplicatedStorage.Remotes.Connect.OnServerEvent:Connect(function()
	text.nu.Value += 10
	task.wait()
	text.Text = text.nu.Value
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.