Currently trying to make a remote event Rebirth System

So I started working on a rebirth system using remotevents, This is what I got so far

Server:

local function returnRebirthInfo(amount)
	for i, info in pairs(RebirthModule) do
		if info.Amount == amount then
			return info
		end
end
return RebirthModule[1]
end

Event.OnServerEvent:Connect(function(player, amount)
	local rebirthInfo = returnRebirthInfo(amount)

	if rebirthInfo ~= nil then
		if player.leaderstats.Coins.Value > rebirthInfo.Cost then
			player.leaderstats.Coins.Value = 0
			player.leaderstats.Rebirths.Value += rebirthInfo.Amount
		end
	end
end)

Module:

local Rebirths = {
	[1] = {Amount = 1, Cost = 100},

}

return Rebirths

Localscript:

for i,v in pairs(RebirthsModule) do
	script.Parent.Text = v["Amount"] .. " Rebirths for " .. v["Cost"] .. " Coins"
	script.Parent.Name = v["Amount"]
end
for _,v in pairs (rebirths.List.Holder.rebirth:GetChildren()) do
	if v:IsA("TextButton") then
		v.Buy.MouseButton1Click:Connect(function()
			Event:FireServer()
		end)
	end
end

so my problem is that the studio and console dont throw any Errors but the game dosent react/remove/give the coins or rebirths, the main reason I am using a amount system is so I can add new Buttons in the feature, I have been trying for some time now and I cant find any solution to make it work. Help would be very nice

You’re not passing an amount as an argument when you’re calling Event:FireServer().

might sound dumb but how would I do that?, I am rather new to that stuff

Event.OnServerEvent:Connect(function(player, amount) --where did the amount argument come from ?

Event:FireServer() --you're not sending the amount argument here

You can set an attribute to the button that stores the amount for the rebirth that that button represents, then pass that amount as an argument. Here’s an example:

button:SetAttribute("Amount", --[[Amount here]])

Passing the amount as an argument:

event:FireServer(button:GetAttribute("Amount"))

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