So I have this money script that gives you cash when you press a button, depending if you have the cash, but when you withdraw the cash, it gives you the tool as many times as there are people in the server, for instance if there was 7 people in the game, I would get 7 cash tools, any help?
Server Script (Receiver)
game:GetService("ReplicatedStorage").Remote.OnServerEvent:Connect(function(player,rcash) print("Going") if rcash > player.leaderstats.Cash.Value then return end print(rcash) local tool = game:GetService("Lighting").Money:Clone() tool.Parent = player.Backpack tool.MoneyValue.Value = rcash end)
Client (Fire To Server)
--Client local currency = "Cash" -- Change this to the currency you want to use local button = script.Parent local setter = button.Parent.AmountBox debounce = false print(100) function chaching() button.Image = "http://www.roblox.com/asset/?id=96539788" wait(1) button.Image = "http://www.roblox.com/asset/?id=96539352" end function errormessage() setter.ErrorText1.Visible = true wait(3) setter.ErrorText1.Visible = false end function notenough() setter.ErrorText2.Visible = true wait(3) setter.ErrorText2.Visible = false end function onClick() print(1) if debounce == false then print(1) local player = game.Players.LocalPlayer print(1) if tonumber(setter.Text) and tonumber(setter.Text) % 1 == 0 and tonumber(setter.Text) >= 1 then print(1) local amount = setter.Text print(1) local cash = player.leaderstats:FindFirstChild(currency) print(1) if tonumber(amount) <= cash.Value or tonumber(amount) == cash.Value then cash.Value = cash.Value - tonumber(amount) print(1) game:GetService("ReplicatedStorage").Remote:FireServer(tonumber(amount)) else print(1) notenough() end else errormessage() end end end script.Parent.MouseButton1Click:Connect(onClick)