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

"A script has been running for a long time, and may be hanging." How to fix?

For some reason, I've been getting this error message that requires me to kill my script when I'm testing out my game. Here are the scripts:

local button = script.Parent.TextButton
local frame = script.Parent.Frame

local function findValue()
	local moneyCount = game.Players.LocalPlayer.MoneyCount
end

local function addMoney()
	moneyCount.Value = moneyCount.Value + 1
end

game.Players.PlayerAdded:Connect(findValue)
button.MouseButton1Click:Connect(addMoney)
local frame = script.Parent.Frame
local button = script.Parent.TextButton

function getMoney()
	frame:TweenPosition(UDim2.new(0.5,-100,0.5,-25),'Out','Quint',.5)
	wait(.75)
	frame:TweenPosition(UDim2.new(0.5,-100,10,-25),'In','Quint',.5)
end

button.MouseButton1Click:Connect(getMoney)
local gui = script.Parent
local display = gui.MoneyAmount
local money = game.Players.LocalPlayer.MoneyCount

while true do
	display.Text = money.Value
end

These are both local scripts. I have no idea what this error message means. Help would be appreciated!

EDIT: Another local script. This may be the problem.

1 answer

✓ Accepted answer

This error typically begins with a loop that is running fast and permanently. Did you show the full script? I don't think so. EDIT: There we go, you finally showed the rest.

while true do
end

That will allways cause that error. Add a wait(0.5) in there to stop it from going too fast

2 comments

0

I'll add an edit with another localscript

0

Thank you very much! That really helped me!

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