My tool won't appear when moved from ServerStorage to StarterPack by a script!

What do you want to achieve?
I want to make a tool that is obtained after completing a series of steps. The last one involves using a ProximityPrompt.

What is the issue?
The tool isn’t appearing in the player inventory, even though it was successfully moved to the StarterPack (It does show when it is available upon spawning).

What solutions have you tried so far?
I tried storing it inside a model inside the workspace, but that made it invisible and unavailable when the game was running (it reappeared when I stopped the game).

Shown below is the script that is directly involved with the tool:

local ProximityPromptService = game:GetService("ProximityPromptService")

local function onPromptTriggered(promptObject, player)
	if promptObject == script.Parent then
		local PortalNode = game.ServerStorage.PortalNode
		PortalNode.Parent = game.StarterPack
		script.Parent.Enabled = false
	end
end

--unused
local function onPromptHoldBegan(promptObject, player)

end

--unused
local function onPromptHoldEnded(promptObject, player)

end

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)
ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)
ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

Change portalNode.Parent to player.Backpack.

1 Like

How do I define player.Backpack?

Replace

PortalNode.Parent = game.StarterPack

with

PortalNode.Parent = player.Backpack

as you already have player as the second parameter in your onPromptTriggered function.

Oh. I wasn’t seeing the list of scripting suggestions showing the backpack option (for example, if you were to type “game.” a list of options like “workspace”, “StarterPack”, “ServerStorage”, and more would appear). Thanks!

1 Like

No problem! Sorry for the delayed / short answers as I’m on mobile atm.

StarterPack is just a container on the server where the tools inside will be copied to all players (to the container player.Backpack) when they spawn. As you don’t want all players to always spawn with the tool, we are just moving it straight from it’s location to player.Backpack.

Also, you should consider using :Clone() on the PortalNode tool to make a copy of it rather than just parenting the original tool, since the tool will no longer be available in ServerStorage if you just move it. This would be a problem if you ever need the tool to be copied again.