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

Give Tool to Player upon MoveTo

Asked by
bloxxyz 274 Moderation Voter
10 years ago

Okay, so this script is seemingly long. But I just have a problem with a couple lines. I'll comment out the portion I need help with. But before you read, here's the problem:

I'm trying to make the Player receive a tool titled "Sword" upon position movement. Everything works well, it loops successfully, the tool is added and removed, but it doesn't show in the Player's inventory. It just shows it in StarterPack temporarily but the player has is in no way capable of reaching it through each round. If someone can please help, as mentioned before, the assumed main problem area is commented out. Thanks a lot, here's the full script:

minigames = game.Lighting.minigame:GetChildren()

h = Instance.new("Hint", game.Workspace) 

while true do 
if game.Players.NumPlayers > 1 then 
    h.Text = "Starting new round.." 
    RandomGame = math.random(1, #minigames) 
    ChosenGame = minigames[RandomGame]
    wait(4)
    h.Text = "Game Chosen:" .. ChosenGame.Name
    GameChosenClone = ChosenGame:Clone()
    GameChosenClone.Parent = game.Workspace
    wait(3)
    spawns = GameChosenClone.Spawns:GetChildren() 
    --tool = game.Lighting.Sword:Clone() 
    --for i,v in pairs(game.Players:GetPlayers()) do
    --name = v.Name
    --check = game.Workspace:FindFirstChild(name) 
    --if check then 
        --checkHumanoid = check:FindFirstChild("Humanoid") 
        --if checkHumanoid then 
            --check:MoveTo(spawns[i].Position)
            --wait(3)
            --tool.Parent = game.StarterPack
        end

        end
    end
    for i = 3,1,-1 do 
        h.Text = "Game will start in" .. i 
    end

    for i = 10,1, -1 do 
        h.Text = "Game ends in.." .. i 
        wait(1) 
    end
    h.Text = "Game has ended!" 
    GameChosenClone:Destroy() 
    tool:Destroy() 
    wait(2)
else
    h.Text = "Game cannot start unless there are 2+ players" 
end
wait(1)
end

2 answers

Log in to vote
3
Answered by 10 years ago
player.Character:MoveTo(Position)
game.Lighting.Tool:Clone().Parent = player.Backpack
0
 Didn't work, thanks though, I gave you rep anyway. bloxxyz 274 — 10y
0
Did you correctly replace everything in my code? broboch479 15 — 10y
0
18cwatford explained it to me a little more, I didn't fully use your code because I assumed you didn't have to clone the tool again, but I guess you do. Thanks for the help. bloxxyz 274 — 10y
0
No problem. broboch479 15 — 10y
Ad
Log in to vote
1
Answered by
User#2 0
10 years ago

You have one clone of the tool, tool, and you are trying to parent that to all the players. To fix this, you just Clone the tool when you're going to parent it.

tool:Clone().Parent = v.Backpack
0
Thank you! I have tried many combinations including v.Backpack and I could not get it to work. I didn't realize you had to clone it a second time. Thank you, I give you rep. bloxxyz 274 — 10y

Answer this question