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

Script Works in Studio Mode But Not in Online Mode?

My script works 100% how it should in studio but when i test it in online mode, the deposit and withdraw functions dont work how they should. Everything eles works fine. 2 Scripts are used, ATM_Engine and Interest.

ATM_Engine Script

wait(15)
amount = game.ServerStorage.ATMStorage.Amount.Value
cash1 = game.ServerStorage.ATMStorage.CashInBank.Value
cashvalue = script.Parent.Screen.SurfaceGui.CashValue1
cashvaluehold = 0
function click1()
	if amount == 0 then
		amount = amount + 1
	else
		amount = amount * 10
		amount = amount + 1
	end
end
function click2()
	if amount == 0 then
		amount = amount + 2
	else
		amount = amount * 10
		amount = amount + 2
	end
end
function click3()
	if amount == 0 then
		amount = amount + 3
	else
		amount = amount * 10
		amount = amount + 3
	end
end
function click4()
	if amount == 0 then
		amount = amount + 4
	else
		amount = amount * 10
		amount = amount + 4
	end
end
function click5()
	if amount == 0 then
		amount = amount + 5
	else
		amount = amount * 10
		amount = amount + 5
	end
end
function click6()
	if amount == 0 then
		amount = amount + 6
	else
		amount = amount * 10
		amount = amount + 6
	end
end
function click7()
	if amount == 0 then
		amount = amount + 7
	else
		amount = amount * 10
		amount = amount + 7
	end
end
function click8()
	if amount == 0 then
		amount = amount + 8
	else
		amount = amount * 10
		amount = amount + 8
	end
end
function click9()
	if amount == 0 then
		amount = amount + 9
	else
		amount = amount * 10
		amount = amount + 9
	end
end
function click0()
	amount = amount * 10
end
function show2()
	wait(1)
	script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
	script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
end
function cancel()
	amount = "0"
	script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
	script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
end
function deposit()
	player1 = game.Players.LocalPlayer
	servermoney = game.ServerStorage.MoneyStorage:FindFirstChild(player1.Name)
	if servermoney.Value >= amount then
		wait(3)
		cash1 = cash1 + amount
		cashvalue.Text = "$" .. cash1
		servermoney.Value = servermoney.Value - amount
		wait(1)
		amount = 0
		script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
		script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
	else
		script.Parent.Screen.SurfaceGui.Deposit.Text = "Not enough cash!"
		script.Parent.Screen.SurfaceGui.Withdraw.Text = "Not enough cash!"
		wait(3)
		amount = 0
		script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
		script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
	end
end
function withdraw()
	player1 = game.Players.LocalPlayer
	servermoney = game.ServerStorage.MoneyStorage:FindFirstChild(player1.Name)
	if cash1 >= amount then
	wait(3)
	cash1 = cash1 - amount
	cashvalue.Text = "$" .. cash1
	servermoney.Value = servermoney.Value + amount
	wait(1)
	amount = 0
	script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
	script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
	else
	script.Parent.Screen.SurfaceGui.Deposit.Text = "Not enough cash!"
	script.Parent.Screen.SurfaceGui.Withdraw.Text = "Not enough cash!"
	wait(3)
	amount = 0
	script.Parent.Screen.SurfaceGui.Deposit.Text = "$" .. amount
	script.Parent.Screen.SurfaceGui.Withdraw.Text = "$" .. amount
	end	
end
function interest()
	cashvalue.Text = "$" .. cash1 * 1.01
	cash1 = cash1 * 1.01
end
script.Parent.Base.SurfaceGui.a1.MouseButton1Click:connect(click1)
script.Parent.Base.SurfaceGui.a1.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a2.MouseButton1Click:connect(click2)
script.Parent.Base.SurfaceGui.a2.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a3.MouseButton1Click:connect(click3)
script.Parent.Base.SurfaceGui.a3.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a4.MouseButton1Click:connect(click4)
script.Parent.Base.SurfaceGui.a4.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a5.MouseButton1Click:connect(click5)
script.Parent.Base.SurfaceGui.a5.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a6.MouseButton1Click:connect(click6)
script.Parent.Base.SurfaceGui.a6.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a7.MouseButton1Click:connect(click7)
script.Parent.Base.SurfaceGui.a7.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a8.MouseButton1Click:connect(click8)
script.Parent.Base.SurfaceGui.a8.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a9.MouseButton1Click:connect(click9)
script.Parent.Base.SurfaceGui.a9.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.a0.MouseButton1Click:connect(click0)
script.Parent.Base.SurfaceGui.a0.MouseButton1Click:connect(show2)
script.Parent.Base.SurfaceGui.Cancel.MouseButton1Click:connect(cancel)
script.Parent.Screen.SurfaceGui.Confirm2.MouseButton1Click:connect(deposit)
script.Parent.Screen.SurfaceGui.Confirm1.MouseButton1Click:connect(withdraw)
game.ServerStorage.ATMStorage.OnOff.Changed:connect(interest)

Interest Script

function run()
local i = 1
while i < 10 do
	wait(60)
	game.ServerStorage.ATMStorage.OnOff.Value = not game.ServerStorage.ATMStorage.OnOff.Value
end
print("done2")
end
run()

Filetree1: http://prntscr.com/8oq26q Filetree2: http://prntscr.com/8oq4x7

The main aim of these scripts are too allow the used to deposit money from the server storage into the "ATM" and it gains interest before allow them to take it out again. Only started scripting 8 days ago and wanted to create this as my first project.

2 comments

0

Why do you want us to fix a 129 line script? Please just post the part that's erroring so we don't have to find it; it makes things easier.

0

The error in online mode is http://prntscr.com/8oqqht

2 answers

Try making your script a LocalScript. it still doesn't work, please just include the bit that's erroring.

1 comment

0

Converted whole ATM_Engine script to a local script, none of the buttons worked. No errors displayed in log from the script. Local Log: http://prntscr.com/8oqnub . Server log: http://prntscr.com/8oqocw . Tested in online mode.

game.Players.LocalPlayer does not work to find the player...

local plr = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
plrn = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Name

is how I found the player and player name. this works if clicked on a click detector.

localplayer is not actually the player.

1 comment

0

But i cant add a click detector to the surfacegui textbutton, how would i implement this onto that.

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