Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fix Model not cloning into camera using tool?

Asked by 4 years ago

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.

0
I answered your question regarding the error so accept my answer!!! User#24403 69 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

Ad
Log in to vote
-2
Answered by
Serpawh -4
4 years ago
Edited 4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

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...

0
Tried it and still it doesnt work wiktormont 14 — 4y
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. Serpawh -4 — 4y
0
And because of you I lost some rep, so you're on your own bud. Serpawh -4 — 4y
0
I didn't want man,there is no errors at all. wiktormont 14 — 4y

Answer this question