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

Tool doesnt work when its cloned onto Backpack. Help?

Im trying to clone an item from ReplicatedStorage to Backpack, but the tool wont work, theres no error that comes out on the output, ive tried using RemoteEvents's to fix this but to no luck. Ive been having this problem since last week. Heres the script for the tool and the cloning script:

Tool (LocalScript):

local player = game.Players.LocalPlayer
local char = player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local enabled = false
local sound = Instance.new("Sound", script.Parent)
sound.SoundId = "http://www.roblox.com/asset/?id=10722059"
local anim = Instance.new("Animation", script.Parent)
anim.AnimationId = "rbxassetid://4004681604"
local loadanim = hum:LoadAnimation(anim)

script.Parent.Parent.Activated:Connect(function()
	if not enabled then
		enabled = true
		loadanim:Play()
		sound:Play()
		wait(4.25)
		hum:RemoveAccessories()
		for i, character in pairs(char:GetDescendants()) do
			if character:IsA("Shirt") then
				character:Destroy()
			end
			if character:IsA("Pants") then
				character:Destroy()
			end
			if character:IsA("ShirtGraphic") then
				character:Destroy()
			end
			if character:IsA("BasePart") then
				game.ReplicatedStorage.ServerEvent:FireServer(character) --This turns the character's color into orange.
			end
		end
		enabled = false
	end
end)

Cloning Script (Server Script):

script.Parent.ClickDetector.MouseClick:Connect(function(obj)
	local neededamount = 30
	local item = game.ReplicatedStorage["Fanta"]
	local leaderboard = obj:WaitForChild("leaderstats")
	local mons = leaderboard.mons
	if mons.Value >= neededamount or mons.Value == neededamount then
		mons.Value = mons.Value - neededamount
		local newitem = item:Clone()
		newitem.Parent = obj.Backpack
	end
end)

2 answers

NVM guys, turns out the problem was the character variable. Thanks iuclds and everyone who was probably about to answer :).

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