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

why is this script not working? no errors... just doesn't work

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)


1 comment

0

Make sure the value's are actually there and if not then create a new instance of them.

2 answers

Answered a very similar question yesterday

The question

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

4 comments

0

what if for the datastore the value already exists

0

what if the second script still doesn

0

what if the second script still doesn't work?

0

nvm i'll just change it

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)

2 comments

0

but thats what i did

0

well idk then

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