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

1local ReplicatedStorage = game.ReplicatedStorage
2local V_tool = ReplicatedStorage.v_Tool
3local Tool = script.Parent
4 
5Tool.Equipped:Connect(function()
6    V_tool:Clone().Parent = workspace.CurrentCamera
7end)

I used even functions

01local ReplicatedStorage = game.ReplicatedStorage
02local V_tool = ReplicatedStorage.v_Tool
03local Tool = script.Parent
04 
05Tool.Equipped:Connect(function()
06    CloneToCamera()
07end)
08 
09function CloneToCamera()
10V_tool:Clone().Parent = workspace.CurrentCamera
11end

It still doesnt work so I'm confused.

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

2 answers

Log in to vote
0
Answered by 5 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
5 years ago
Edited 5 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.

01local function findTool()
02local V = game:GetService("ReplicatedStorage")['V_tool']
03if V == nil then -- fix it;
04else return V;
05end
06 
07 
08V_tool = findTool()
09V_tool.Archivable = true
10V_tool:Clone.Parent = game.Workspace.CurrentCamera
11if assert(game.Workspace.CurrentCamera:FindFirstChild('V_tool') then
12print"cloned"
13else
14V_tool:Clone().Parent = game.Workspace.CurrentCamera
15end

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

Answer this question