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

Tool to Workspace after Player Removed?

Basically whenever I have a tool, I want the parent to be workspace. I've been testing and nothing has been working.

players=workspace.PLAYERS
local player = game.Players.LocalPlayer
local character = player.Character or player.Character:wait()

game.Players.PlayerRemoving:connect(function(player)
	local f=character:GetChildren()
	for i=1,#f do
		if f[i].ClassName == "Tool" or f[i].ClassName == "Part" then -- the part that doesnt work
			f[i].Parent=workspace
		else
		end
	end 
	local v=players.RED:GetChildren()
	for i=1,#v do
		if v[i].Value==player.Name then
			v[i].Value=""
		else
		end
	end
	local c=players.BLUE:GetChildren()
	for i=1,#c do
		if c[i].Value==player.Name then
			c[i].Value=""
		else
		end
	end
end)

Thanks for all the help,

LukeGabrieI aka EnergyBrickz

2 answers

Just do this

workspace:FindFirstChild("LukeGabrieI"):Find

4 comments

0

that doesnt do anything lol

0

sorry, im not very good at scripting

0

i know i suck, please forgive me im trying to do the best i can ;-;

0

thanks for helping tho gg

What you did on the first line is wrong becuase you missed out game and plus Players shouldnt be all capital.

players = game.workspace.Players
local player = game.Players.LocalPlayer
local character = player.Character or player.Character:wait()

game.Players.PlayerRemoving:connect(function(player)
    local f=character:GetChildren()
    for i=1,#f do
        if f[i].ClassName == "Tool" or f[i].ClassName == "Part" then -- the part that doesnt work
            f[i].Parent=workspace
        else
        end
    end 
    local v=players.RED:GetChildren()
    for i=1,#v do
        if v[i].Value==player.Name then
            v[i].Value=""
        else
        end
    end
    local c=players.BLUE:GetChildren()
    for i=1,#c do
        if c[i].Value==player.Name then
            c[i].Value=""
        else
        end
    end
end)

4 comments

0

There's a model inside Workspace called PLAYERS lol, it stores values for players that join.

0

oh. Then do game.Workspace.PLAYERS

0

wait.. what

0

Im getting confused.

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