I modified your code a little, if you don’t understand something, just ask me and I’ll answer as soon as possible
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayerDetect")
local Type1 = script.Parent.Parent.TextBox
local Type2 = script.Parent.Parent.Parent.Frame.Cash
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer(Type1, Type2)
end)
ServerScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("PlayerDetect")
RemoteEvent.OnServerEvent:Connect(function(player, Type1, Type2)
Type1 = tonumber(Type1.Text)
Type2 = tonumber(Type2.Text)
if Type1 <= Type2 and Type1 > 0 then
player.leaderstats.Cash.Value += Type1
else
print("Not enough Cash")
end
end)
I hope it works, I didn’t have time to test