Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i take money from the player?

Asked by 3 years ago
Edited 3 years ago
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

0
um pls write it by lua Omerevkizel 27 — 3y
0
ok sorry jedistuff2 89 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
-- 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)
0
thanks so much! It really helped jedistuff2 89 — 3y
0
No problem also make my answer the solution WoGiTeam 60 — 3y
Ad

Answer this question