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

Why isint this OnTouched TP Brick Working?

FYI: when a round starts all the players are put into an "InGame" folder so that's why I put that in the script

Everything in this script seems to work besides the teleport, I want to teleport everyone in the server.



wait(5)
local Part = script.Parent
local Debounce = false
local Players = game.Workspace.InGame:GetChildren()
local TPTo = game.Workspace.MainSpawn

Part.Touched:Connect(function(hit)
	if not Debounce then
	Debounce = true
		if hit.Parent:FindFirstChild("Humanoid") then
	   	 	local humanoid = hit.Parent:FindFirstChild("Humanoid")
			print(hit.Parent)
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    		player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
			player.leaderstats.Bits.Value = player.leaderstats.Bits.Value + 25
        	print (player)
			print (player.leaderstats.Wins.Value)
			wait(5)
			for _, v in pairs (Players)
			do
				local TPOb = v.HumanoidRootPart
				TPOb.CFrame = CFrame.new(TPTo.Position)
			end
		Debounce = false
		end
	end
end)

1 answer

I don't understand the ingame folder. You could just of but a bool value inside the player.

wait(5)
local Part = script.Parent
local Debounce = false
local TPTo = game.Workspace.MainSpawn

Part.Touched:Connect(function(hit)
    if not Debounce then
    Debounce = true
        if hit.Parent:FindFirstChild("Humanoid") then
            local humanoid = hit.Parent:FindFirstChild("Humanoid")
            print(hit.Parent)
            local player = game.Players:GetPlayerFromCharacter(hit.Parent)
            player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
            player.leaderstats.Bits.Value = player.leaderstats.Bits.Value + 25
            print (player)
            print (player.leaderstats.Wins.Value)
            wait(5)
	for _,v in pairs(game.Players:GetChildren()) do
		local TPOb = v.Character.HumanoidRootPart
                TPOb.CFrame = CFrame.new(TPTo.Position)
	end
        Debounce = false
        end
    end
end)


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