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

I've been trying to make a efficient way to teleport a player and remove all the items. How can you?

I've probably not have been specifying enough on my other posts.

I've been trying to fix the code below

I think that the

game.Players[v].Character.Humanoid:UnequipTools()
game.Players[v].Backpack:ClearAllChildren()

is wrong in the script, but I might be wrong.

below The part of the script that the code is in (In case you need it)

if #_G.gameplayers == 1 then
	for i, v in pairs (_G.gameplayers) do
		if v ~= nil then
			status.Value = v..' Is The WINNER!'
			print 'Game Over!'
			game.Players[v].leaderstats.Wins.Value = game.Players[v].leaderstats.Wins.Value + 1
			game.Players[v].leaderstats.Rating.Value = game.Players[v].leaderstats.Rating.Value + 4
			game.Players[v].Character.Humanoid:UnequipTools()
			game.Players[v].Backpack:ClearAllChildren()
			print 'Gave winning player point!'

			break
		elseif #_G.gameplayers == 0 then
			status.value = 'No one won :('
			end
	end
	break
else
	status.Value = i..' seconds left!'
end

end

Thank You!

1 answer

✓ Accepted answer

Destroy items

for i,v in pairs(game.Players:GetChildren()) do --Get all children of players
    Backpack = v:FindFirstChild("Backpack",true)
    if Backpack ~= nil then  --Check if the child has a backpack
        c = Backpack:GetChildren() --Get the children of the backpack
        for i = 1,#c do
            c[i]:Destroy() --Use Destroy method instead
        end
    end
end)

Teleporting(CFrame) http://robloxdev.com/articles/How-to-teleport-within-a-Place

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