ModuleScript will execute half the time, not execute the other half in Studio

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.

Try print debugging? Maybe it will help you to find out which line is wrong.

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
		print("could not find "..item2.." in "..item1)
		return false
	end
end

function tycoon.claimBase(plr,values,device,whoOwns)
	if valid(values,"owner") == true then
		values.owner.Value = plr
	end
	if valid(whoOwns,"gui") == true then
		whoOwns.gui.label.Text = values.typ.Value..": "..plr.Name
	end
	device:Destroy()
end

return tycoon

There are supposed to be print statements that state if they could or could not find whatever we are looking for. It seems that the code jumps over those lines and just goes straight to the :Destroy() line. No errors or statements, nothing.

just got this from DevConsole in play mode, could not get it from output in studio.
Roblox (gyazo.com)

I have no clue why Output is being useless inside studio

EDIT: Fixed it.