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

How can I make it so that when a play leaves the text resets?

I tried doing it like taking there name and seeing but nope I want it so that when they go offline out of the game it resets the text to Become Owner and I want to also add When they leave it resets the the door back to transparent to 0 and cancollide to true after

while true do
function onTouch(hit)
    local name = hit.Parent.Name
    local player = hit.Parent
    local plr = hit.Parent:FindFirstChild("Humanoid")
     if plr then
    local check1 = game.Players:GetPlayerFromCharacter(hit.Parent)
      if check1 then
        local check2 = check1:WaitForChild("leaderstats")
          if check2 then
            local check3 = check2:WaitForChild("Owner")
              if check3.Value == false then
                  check3.Value = true
                  script.Parent.CanCollide = false
                  script.Parent.Transparency = 1
                print(hit.Parent)
                local model = script.Parent.Parent
                model.Name = name.." Owns This Tycoon"
                local green = game.Teams.GreenTeam
                check1.TeamColor = BrickColor.new("Lime green")
                local h = player:FindFirstChild("Humanoid")
                if h then
	            h.Health = 0
	            plr:WaitForChild("Humanoid")
	            plr.Position = script.Parent
	            if name then
		            print("Good")
	              else model.Name = "Become Owner"
	                     end
                     end        
                end
            end
        end
    end
end
script.Parent.Touched:connect(onTouch)
wait(1)
end


2 comments

0

There's no reason to put your code in a loop.

0

Well I did that so that it would check the whole time to see if a player went offline

1 answer

✓ Accepted answer

You should use This, make this a regular script in the workspace or server script service

I would recommend making a function that resets the tycoon once they leave instead of leaving it there until some other player touches it

game.Players.PlayerRemoving:connect(function(player)
   -- Code Here
end)

what this basically does is do whatever is inside the code whenever a player leaves the game

Hope this has helped

2 comments

0

Um, How can I remove the exact one theres 8 tycoons and I only want to reset on the player the one that left

0

make it find the tycoon with a specific name of the person who left

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