I have a wierd bug that I dont know how to fix

So I’m working on making a fake donation system for an admin panel that will put a chat message saying the user donated robux, but for some reason the message sends multiple times depending on how many people are in the server (1 person sends 1 time 2 people sends 2 times etc) and i have no idea how or why its happening.
Scripts:

--Local script inside button
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.GetLocalPlayer:FireServer()
end)
--Server script inside button
local Players = game:GetService("Players")

local RepStore = game.ReplicatedStorage

game.ReplicatedStorage.GetLocalPlayer.OnServerEvent:Connect(function(Player)
		RepStore.BoughtEvent1:FireAllClients(Player)
end)
--Local script inside StarterCharacterScripts
local TCS = game:GetService("TextChatService")

local RepStore = game.ReplicatedStorage

RepStore.BoughtEvent1.OnClientEvent:Connect(function(player)
	local msg = TCS.TextChannels.RBXGeneral:DisplaySystemMessage(`<font color='{"#00ff44"}'>{"5 robux donation has been purchased by "..player.Name}</font>`)
end)

any solutions would be super helpful ^^ Thanks!

You are creating a server script for each player because your *server script is inside the button, what you should do is move the server script inside ServerScriptService

1 Like

Move server script to ServerScriptService

Hi, sorry I took so long to mark it as a solution. After I finished testing I went to sleep and kinda forgot about this xd

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