Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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)


0
Make sure the value's are actually there and if not then create a new instance of them. Meltdown81 309 — 5y

2 answers

Log in to vote
0
Answered by
worklok -24
5 years ago

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)
0
but thats what i did JohnerDev 27 — 5y
0
well idk then worklok -24 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

0
what if for the datastore the value already exists JohnerDev 27 — 5y
0
what if the second script still doesn JohnerDev 27 — 5y
0
what if the second script still doesn't work? JohnerDev 27 — 5y
0
nvm i'll just change it JohnerDev 27 — 5y

Answer this question