Why isn't my remote event firing?

Hi, I have got a local script that fires a remote event and passes some info to the server script. But the leaderstats value isn’t changing so I’m guessing the remote event isn’t being fired at all. Any idea why? Thanks.

Local script:

local Ms = game:GetService("MarketplaceService")

local button = script.Parent

button.MouseButton1Click:Connect(function()
	
	local player = game.Players.LocalPlayer
	local itemId = button.Value.Value
	local itemPrice = button.Price.Value
	
	Ms:PromptPurchase(player, itemId)
	
	Ms.PromptPurchaseFinished:Connect(function(player, itemId, was_purchased)
		
		if was_purchased then
			
			type creator = {CreatorTargetId: number, CreatorType: string, 
				HasVerifiedBadge: boolean, Id: number, Name: string}

			local function getItemCreator(itemId: number): creator
				local info = Ms:GetProductInfo(itemId)
				return info.Creator
			end
			
			local creator = getItemCreator(itemId)
			local winnerName = creator.Name
			
			local text = "[SYSTEM] "..player.." donated "..itemPrice.." robux to "..winnerName
			game.Workspace.SystemMessage:FireServer(text, itemPrice)
		end

	end)
end)

Server script:

local TextService = game:GetService("TextService")

game.Workspace.SystemMessage.OnServerEvent:Connect(function(player, text, itemPrice)
	player.leaderstats.Donated.Value += itemPrice
	local playerId = player.UserId
	local filteredTextResult = TextService:FilterStringAsync(text, playerId)
	game.StarterGui:SetCore( "ChatMakeSystemMessage",  { text, Color = Color3.fromRGB( 255,0,0 ), Font = Enum.Font.Arial, FontSize = Enum.FontSize.Size24 } )
end)
2 Likes

Your script is very unsafe, exploiters can make remote event calls and change their donated value to anything they like. You should handle the purchases at the serverscript

4 Likes

Try adding prints to ensure if the scripts are running and the remote is firing correctly.
You should do what the reply above says as well

3 Likes