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

R6 backpack script not working on R15? Tried fixing script not showing up.

Hi! My backpacks have already been scripted, and work properly in giving the player tools, the only problem is they do not show up on an R15 character, I have the script for the torso, but it only works in r6 which is what im used to. But I would like to upgrade it to R15, so I did some experiments with using the accessory property menu and positioning it to the character, but the script ended up just breaking any suggestions?

function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") ~= nil and hit.Parent:findFirstChild("Chest") == nil then
local g = script.Parent.Parent.Chest:clone()
g.Parent = hit.Parent
local C = g:GetChildren()
for i=1, #C do
if C[i].className == "Part" or C[i].className == "UnionOperation" then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle

end
local Y = Instance.new("Weld")
Y.Part0 = hit.Parent.Torso
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
end
local h = g:GetChildren()
for i = 1, # h do
h[i].Anchored = false
h[i].CanCollide = false
end
end
end
script.Parent.Touched:connect(onTouched)
local model = script.Parent.Parent.Parent
local backpack = model.Backpack:clone()
script.Parent.Touched:connect(function(hit)
local h = hit.Parent:findFirstChild("Humanoid")	
backpack.Parent = h.Parent
backpack.Handle.Anchored = false
end)

3 comments

0

R15 has UpperTorso and LowerTorso while R6 has just Torso.

0

Use HumanoidRootPart or Upper and LowerTorso as 6zk8 said.

0

how would i incorporate that into the script?

1 answer

function onTouched(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil and hit.Parent:FindFirstChild("HumanoidRootPart") == nil then
		local g = script.Parent.Parent.HumanoidRootPart:Clone()
		g.Parent = hit.Parent
		local C = g:GetChildren()
		for i = 1, #C do
			if C[i].ClassName == "Part" or C[i].ClassName == "UnionOperation" then
				local W = Instance.new("Weld")
				W.Part0 = g.Middle
				W.Part1 = C[i]
				W.Part1 = C[i]
				local CJ = CFrame.new(g.Middle.Position)
				local C0 = g.Middle.CFrame:inverse() * CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = g.Middle
			end
			local Y = Instance.new("Weld")
			Y.Part0 = hit.Parent.HumanoidRootPart
			Y.Part1 = g.Middle
			Y.C0 = CFrame.new(0, 0, 0)
			Y.Parent = Y.Part0
		end
		local h = g:GetChildren()
		for i = 1, #h do
			h[i].Anchored = false
			h[i].CanCollide = false
		end
	end
end

script.Parent.Touched:Connect(onTouched)

local model = script.Parent.Parent.Parent
local backpack = model.Backpack:clone()

script.Parent.Touched:Connect(function(hit)
	local h = hit.Parent:FindFirstChild("Humanoid")
	backpack.Parent = h.Parent
	backpack.Handle.Anchored = false
end)

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