I'm trying to create a script where you touch a door and it will check whether or not you own a tycoon and either make you the owner of the new tycoon if you don't or do nothing if you already own a tycoon.
If anyone can alter this script or give me some sort of help as to how I can accomplish this to work while being server-sided then I'd greatly appreciate it as I am completely at a loss as to where I can even begin.
wait(2)
local tycoon = game.Workspace.Tycoon1
local owner = tycoon.Main.Owner
local debounce = false
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player ~= nil and debounce == false then
local alert = player.PlayerGui.TycoonGui.Alert
debounce = true
print'Check for Ownership'
if player.Tycoon.Value == 1 then
alert.Text = "You already own a tycoon!"
alert.Type.Value = "Alert"
alert.On.Value = true
return end
owner.Value = player.Name
player.Tycoon.Value = 1
alert.Text = "You now own this tycoon, " ..player.Name.. "!"
alert.Type.Value = "Message"
alert.On.Value = true
for i = 0.4, 1, 0.01 do
wait()
script.Parent.Transparency = i
end
script.Parent.Parent:Destroy()
end
wait(2)
debounce = false
end)

4 comments
Use :Connect instead of :connect, but this won't solve the problem.
Did you get anything from the output?
Please indent your code so it doesn't give me eye spasms :)
make sure
hitis actually a player as well