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

Why won't this put a hyper laser into my backpack when i touch it?

I tried to do what the wiki said but it won't work..Here:

local assetId = 16688968
local instance = game:GetService("InsertService"):LoadAsset(assetId)
local plr = game.Players.PlayerAdded:connect(plr)
local backpack = plr:FindFirstChild("Backpack")
function onTouch()
	
	if instance then
game:GetService("InsertService"):Insert(instance)
instance.Parent = backpack
end
end

script.Parent.Touched:connect(onTouch)

1 answer

The most efficient way of doing this would be to clone the tool from ServerStorage Use:game:GetObjects("rbxassetid://asset id")[1].Parent = Workspace --To get the tool into the game

--Put the tool into ServerStorage
script.Parent.Touched:connect(function(hit)
	wait(1)
	if hit.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local character = hit.Parent
		local backpack = player:FindFirstChild("Backpack")
		if hit.Parent:FindFirstChild("Humanoid").Health >0  and backpack and not backpack:FindFirstChild("Tool") and not hit.Parent:FindFirstChild("Tool")  then
		    local clone = game.ServerStorage.Tool:Clone()
       		clone.Parent = backpack
		end
    end
end)







2 comments

0

BUT if i do that then they are free models and not high quality like the ROBLOX versoins

0

What free models? It's a tool, m8

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