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

Give Tool to Player upon MoveTo

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

player.Character:MoveTo(Position)
game.Lighting.Tool:Clone().Parent = player.Backpack

4 comments

0

 Didn't work, thanks though, I gave you rep anyway.

0

Did you correctly replace everything in my code?

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.

0

No problem.

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

1 comment

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.

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