can you help with this script, has no errors, just doesn't work. Thanks..
local stock = game.Players.LocalPlayer:WaitForChild("Stocks").ONE local cash = game.Players.LocalPlayer:WaitForChild("leaderstats").Cash local test = game.Workspace.teststock local OPrice = game.Workspace.ONEVal.ONEPrice local player = game.Players.LocalPlayer local a = player.PlayerGui.CashNStuff.Frame.Investments.ImageLabel.TextLabel wait(4) print(a.Text) print(OPrice.Value) print(cash.Value) print(stock.Value) script.Parent.MouseButton1Click:connect(function() wait(0.75) if cash.Value >= OPrice.Value then stock.Value = stock.Value + 1 and cash.Value == cash.Value - OPrice.value a.Text = test.Value else print("Not enough cash") end end)
it's because you should only use local
when you are putting a variable inside a function
example:
local p = script.Parent local gui = p.Parent.FindFirstChild("testguibutton") p.MouseButton1Click:connect(function() gui.Visible = true end)
Answered a very similar question yesterday
Also DataStore should be in a modulescript with definition at top and return at the bottom.
For your second script you used StarterGui
instead of PlayerGui
. Just add a line of code and change StarterGui to PlayerGui:
local player = game.Players.LocalPlayer local a = player.PlayerGui.CashNStuff.Frame.Investments.ImageLabel.TextLabel
Edit: Fixed Link