I’m atempting to make a basic tool system with a viewmodel.
For what ever reason when I tried to create a part that removed the tool and the viewmodel i’d get this strange error viewmodel is not a member of the camera even though it is.
-- Here is a example
I’ve tried fixing it with wait for child a multitude of tutorials and even looking for it on devfourms and found nothing. Thanks in advance!
Heres the script that I used for the removal part
-- Im the script
local player = game.Players.LocalPlayer
local Camera = game.workspace.CurrentCamera
local ViewModel
script.Parent.Triggered:Connect(function(player)
local Hand = player.Character
local item = Hand:FindFirstChild("TeddyBear :D")
if item then
ViewModel = Camera.ViewModel
ViewModel:Destroy()
item:Destroy()
end
end)
unfortunately it didn’t work… Heres a video example
It deleted the tool but not the viewmodel, the viewmodel is still a child of camera btw.
-- Heres the new code I made using your example
local player = game.Players.LocalPlayer
local ViewModel
script.Parent.Triggered:Connect(function(player)
local Hand = player.Character
local item = Hand:FindFirstChild("TeddyBear :D")
if item then
item:Destroy()
end
local Camera = workspace.CurrentCamera
ViewModel = Camera:FindFirstChild("ViewModel")
if ViewModel then
ViewModel:Destroy()
end
end)