Very bizarre problem I have. I am using a ModuleScript to code a new tycoon kit for some games, and when I try testing it in Studio, about 50% of the time it will work, and the other half it will not. I test it in normal server mode and there’s no issues.
Server script:
local mainFrame = require(game.ServerScriptService.tycoonFunctions)
local tycoon = script.Parent
---- above is the requires and global variables outside this script needed
local run = game:GetService("RunService")
local plrs = game:GetService("Players")
---- above is the services needed
local values = tycoon:WaitForChild("values",1)
local plrs = game:GetService("Players")
local claimDevice = tycoon:WaitForChild("claimDevice",1)
local whoOwns = tycoon:WaitForChild("whoOwns",1)
---- above are local variables
function incomeGain()
if values.owner.Value ~= nil then
local stats = values.owner.Value:WaitForChild("leaderstats",1)
while wait(values.speed.Value) do
stats.Cash.Value = stats.Cash.Value + values.income.Value
end
end
end
values.owner.Changed:Connect(function()
print("Changed")
spawn(incomeGain)
end)
claimDevice.head.ProximityPrompt.Triggered:Connect(function(player)
mainFrame.claimBase(player,values,claimDevice,whoOwns)
end)
ModuleScript:
local tycoon = {}
local plrs = game:GetService("Players")
local mkt = game:GetService("MarketplaceService")
local gui = script.gui
function valid(item1,item2)
if item1:FindFirstChild(item2) ~= nil then
print("found "..item2.." in "..item1)
return true
else
return false
end
end
function tycoon.claimBase(plr,values,device,whoOwns)
values.owner.Value = plr
whoOwns.gui.label.Text = values.typ.Value..": "..plr.Name
device:Destroy()
end
return tycoon
In the ModuleScript, the item that gets requested to be destroyed gets destroyed; the text in the billboard GUI does not change and neither does the requested value.
I get no output when this issue happens. And then it will work the other times.