Alright, just a few things to begin:
- I don't receive any output errors.
- The script is NOT a localscript
- The script resides in a part along with a click detector.
Here's the script:
local light = game.Lighting.globaltyc
local ipath = game.Workspace.Tycoon.Tycoon.InvInt
local ipath2 = game.Workspace.Tycoon2.Tycoon.InvInt
local btnamnt = 1 -- X is sold each time.
local ltet = 0 -- If money is less than or equal to X, don't allow.
local price = 2 -- X is gained from each item.
script.Parent.ClickDetector.MouseClick:connect(function(hit)
print(hit.Name)
if game.Players:findFirstChild(hit.Name) == light.TycUser1.Value then
if ipath.Stone.Value <= ltet then
print("You need more stone!")
if ipath.Stone.Value > 0 then
ipath.Stone.Value = ipath.Stone.Value - btnamnt
local stats = (hit):findFirstChild("leaderstats")
local cash = stats:findFirstChild("Cash")
cash.Value = cash.Value + price
end
end
end
if game.Players:findFirstChild(hit.Name) == light.TycUser2.Value then
if ipath2.Stone.Value <= ltet then
print("You need more stone!")
if ipath2.Stone.Value > 0 then
ipath2.Stone.Value = ipath2.Stone.Value - btnamnt
local stats = (hit):findFirstChild("leaderstats")
local cash = stats:findFirstChild("Cash")
cash.Value = cash.Value + price
end
end
end
end)
In case you're curious, this script consists of two variants of the same function, except one references a Tycoon and the other references a Tycoon2.
The base of the script (subtracting ore, adding money) works just fine. If I remove the check, it functions just fine. However, the check is required, and seems to be breaking it.
Whenever I go into "Play Solo" mode and click this button, it only outputs "Player1", and nothing else executes.
light.TycUserX.Value is a string value which is automatically assigned when the player joins.
Any help, like always, is greatly appreciated!
