local frame = script.Parent.Frame local button = script.Parent.TextButton local moneycount = game.Players.LocalPlayer.MoneyCount 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 local function addMoney() wait(.5) moneycount.Value = moneycount.Value + 1 wait(1.25) end button.MouseButton1Click:Connect(addMoney) button.MouseButton1Click:Connect(getMoney)
So this script is for whenever I click a button it sends up a message saying you earned money and it adds money to an IntValue. What I want to do is make sure that everytime the message comes up money is added to your IntValue, but when I repeatedly click the button, it adds money and the message doesn't pop up. Can somebody help me?
I think the problem is because you're calling 2 functions!!?!?!??!
Try the following:
local frame = script.Parent.Frame local button = script.Parent.TextButton local moneycount = game.Players.LocalPlayer.MoneyCount --Transforming 2 functions into 1 button.MouseButton1Click:connect(function() frame:TweenPosition(UDim2.new(0.5,-100,0.5,-25),'Out','Quint',.5) wait(.5) moneycount.Value = moneycount.Value + 1 wait(.25) frame:TweenPosition(UDim2.new(0.5,-100,10,-25),'In','Quint',.5) wait(.5) --I don't understand why do you need this wait() in the end, I'll leave it there, but later, you might want to remove it. *might* end)
Ok, so this should be enough. If it works, please mark as the answer!
As always, keep the good scripting!
I am not sure if this is the issue, BUT, I'm not sure if you can have multiple events tied to one listener.
local frame = script.Parent.Frame local button = script.Parent.TextButton local moneycount = game.Players.LocalPlayer.MoneyCount 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 function addMoney() wait(.5) moneycount.Value = moneycount.Value + 1 wait(1.25) end function stuff() addMoney() -- Add the money getMoney() -- Tween a gui end button.MouseButton1Click:Connect(stuff) -- Trigger a new function