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

Message made more than once?

function onTouch(hit)
	local name = hit.Parent.Name
    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 == true then
				local m = Instance.new("Hint",game.Workspace)
				m.Text = name.." Already Owns A Tycoon"
				wait(4)
				m:Destroy()
				wait(.5)
			end
			  if check3 then
				  check3.Value = true
				  script.Parent.CanCollide = false
				  script.Parent.Transparency = 1
				print(hit.Parent)
				end
	 	    end
	    end
    end
end
script.Parent.Touched:connect(onTouch)
wait(1)

I need it to only make 1 message not 8-9?

1 answer

✓ Accepted answer

You could just add a simple check to see if the hint already exists in workspace.

Here is your revised script:

function onTouch(hit)
    local name = hit.Parent.Name
    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 == true then
                local m 
				if game.Workspace:FindFirstChild'Hint' then
					print'Hint exists!'
				else
					m = Instance.new("Hint",game.Workspace)
				end
                m.Text = name.." Already Owns A Tycoon"
                wait(4)
                m:Destroy()
                wait(.5)
            end
              if check3 then
                  check3.Value = true
                  script.Parent.CanCollide = false
                  script.Parent.Transparency = 1
                print(hit.Parent)
                end
            end
        end
    end
end
script.Parent.Touched:connect(onTouch)
wait(1)

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