Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Would this logically make sense?

Im making a tycoon and I am trying to add to my script to see if the owner of the tycoon left.

Im wondering if this would work:

val = script.Parent.OwnerText.SurfaceGui.TextLabel
pl = game:GetService("Players")

if val.Text ~= "No Owner" and pl:FindFirstChild(tostring(val.Text)) == false then
  print("Owner left so no owner")
end

Please answer/help with my question! Thanks.

4 comments

0

Well, it should work but, there is a better way to doing this using game.Players.PlayerRemoving.

0

Could you make an answer explaining it please?

0

Question tho, is this script located under the tycoon?

0

Basically, it's in the owner door part.

1 answer

✓ Accepted answer

Sample script of what I mentioned in the comments:

local Owner = --The tycoon owner value

game.Players.PlayerRemoving:Connect(function(player) --A function that is activated when a player leaves
	if player.Name == Owner.Value then --Check if that player that left was the owner of the tycoon
		print("Owner has left the game")
		--Rest of your code here
	end
end)

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.