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

Please help I can't figure out how to put a local value into server using RemoteEvnets?

Asked by 2 years ago

I am trying to make an ATM, whenever I fire the server and put the variables in the server script, it just prints my values to my players name...

submit = script.Parent

text_box = submit.Parent.Placeholder

plr = game.Players.LocalPlayer

ls = plr:WaitForChild("leaderstats")

bank = ls.Bank

RS = game:GetService("ReplicatedStorage"):WaitForChild("Server")

withdraw = RS:WaitForChild("Withdraw")

submit.MouseButton1Click:Connect(function()
    local text = text_box.Text
    if tonumber(text) then
        local amount = Instance.new("IntValue",script.Parent)
        amount.Name = "Amount"
        amount.Value = text
        local number = amount.Value
        if bank.Value >= amount.Value then
            print("Enough money!")
            withdraw:FireServer(text)
        elseif bank.Value < amount.Value then
            print("Not enough money")
        else
            plr:Kick("Error Code 1, please screenshot your debug and send it to a developer.")
        end
    end
end)
0
1). Nothing can be done without the server-sided code. Ziffixture 6913 — 2y
0
2). Instantiating an IntValue to round the amount is foolish, especially the fact that you don't remove it afterward; you will pile up a mountain of IntValues. Ziffixture 6913 — 2y
0
3). You're still vulnerable to an infinite money exploit. Sanity checks must be carried out on the server as well. Ziffixture 6913 — 2y
0
4). The whitespace between your variables ruins readability. Ziffixture 6913 — 2y

Answer this question