Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i take money from the player?

local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	if player.leaderstats.Coins.Value >= 100
	then
		script.Parent.Roll:FireServer()
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 100
	end
end)

so i made a local script in a gui that takes coins if you have enough (dont mind the remote event) when i get money again it gives 10 coins (the normal amount) plus the amount that the local script took

2 comments

0

um pls write it by lua

0

ok sorry

1 answer

✓ Accepted answer
-- Put this in the LocalScript

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Button = script.Parent
local RollEvent = script.Parent.Roll

Button.MouseButtonDown1:Connect(function()
    RollEvent:FireServer()
end)

-- Add a Script in the same Parent as the LocalScript

local RollEvent = script.Parent.Roll
local Minimum = 100
local Substract = 100

RollEvent.OnServerEvent:Connect(function(plr)
if plr.leaderstats.Coins.Value >= Minimum then
    plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value - Substract
else
   warn(plr.Name.." doesn't have enough!")
end)

2 comments

0

thanks so much! It really helped

0

No problem also make my answer the solution

This discussion is preserved as it was. New answers, comments, and votes are closed.