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

How to fix Model not cloning into camera using tool?

Hi,I recently asked a question where my script didnt work for some reason,even after solution it didnt work. So when I rewrite the script I discovered the problem which is this

local ReplicatedStorage = game.ReplicatedStorage
local V_tool = ReplicatedStorage.v_Tool
local Tool = script.Parent

Tool.Equipped:Connect(function()
	V_tool:Clone().Parent = workspace.CurrentCamera
end)

I used even functions

local ReplicatedStorage = game.ReplicatedStorage
local V_tool = ReplicatedStorage.v_Tool
local Tool = script.Parent

Tool.Equipped:Connect(function()
	CloneToCamera()
end)

function CloneToCamera()
V_tool:Clone().Parent = workspace.CurrentCamera
end

It still doesnt work so I'm confused.

1 comment

0

I answered your question regarding the error so accept my answer!!!

2 answers

So I figured it out!The problem was actually that I didn't put Handle to tool,well stupid me.

We're making a function to just get the 'Tool' object itself.

local function findTool()
local V = game:GetService("ReplicatedStorage")['V_tool']
if V == nil then -- fix it;
else return V;
end


V_tool = findTool()
V_tool.Archivable = true
V_tool:Clone.Parent = game.Workspace.CurrentCamera
if assert(game.Workspace.CurrentCamera:FindFirstChild('V_tool') then
print"cloned"
else
V_tool:Clone().Parent = game.Workspace.CurrentCamera
end

Hello, there is a explanation for what I've done. When I looked up 'workspace' it said it had been deprecated from their servers, therefore, I use 'game.Workspace' in its stead.

Archivable is a property, inherited from Instance, that allows you to Clone something when it is true. It also allows your project to save that particular object.

I used assert() which is a function that checks if what you've put, is true or not. If it is then the if statement carries on like normal, but if it isn't then we included an else to repeat the earlier process of Cloning it.

I'm not sure what's after that...

4 comments

0

Tried it and still it doesnt work

0

Then you need to read out your console log. If there isn't an error, or warning, then you need to catch one like I tried doing.

0

And because of you I lost some rep, so you're on your own bud.

0

I didn't want man,there is no errors at all.

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