Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tool to Workspace after Player Removed?

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago

Just do this

workspace:FindFirstChild("LukeGabrieI"):Find
0
that doesnt do anything lol LukeGabrieI 73 — 7y
0
sorry, im not very good at scripting Dxsigned 12 — 7y
0
i know i suck, please forgive me im trying to do the best i can ;-; Dxsigned 12 — 7y
0
thanks for helping tho gg LukeGabrieI 73 — 7y
Ad
Log in to vote
0
Answered by
phxtn 154
7 years ago

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)
0
There's a model inside Workspace called PLAYERS lol, it stores values for players that join. LukeGabrieI 73 — 7y
0
oh. Then do game.Workspace.PLAYERS phxtn 154 — 7y
0
wait.. what phxtn 154 — 7y
0
Im getting confused. phxtn 154 — 7y

Answer this question