I have a tool that has a script that constantly sets the tool's CFrame to the camera's CFrame with an offset to give it an FPS game like look. That's it.
But when I equip the tool, after some time on random, the tool gets destroyed. When I don't have the tool equipped, it doesn't get destroyed. I am suspecting that when I equip it, the model gets transferred to the workspace and gets affected by gravity, hence falling to the void, but when I log the Y-axis of all the parts, none of them ever are moving downwards, however, their velocities do grow negatively.
I also tried to anchor the tool which caused them to levitate in mid-air instead of being stuck to the camera, but it still got deleted. I also tried to log it ancestor, but it doesn't change at deletion. I have been trying to debug this for about 6 hours now, and I need assistance. Don't hesitate to ask more questions, but I need this solved :)
Note: I did figure this out though: if you equip and unequip the tool very fast, it stops its deletion mysteriously ¯_(?)_/¯
Here's the code:
-- this is a local script because we don't want others to see the floating hands local runService = game:GetService("RunService") local camera = game.Workspace.CurrentCamera local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local viewModel = game.ReplicatedStorage:WaitForChild("player"):WaitForChild("viewModel"):Clone() viewModel.Parent = game.Workspace:WaitForChild("storages"):WaitForChild("local"):WaitForChild("viewModels") local onDie = function () viewModel:Destroy() end humanoid.Died:Connect(onDie) while true do runService.RenderStepped:Wait() viewModel.Head.CFrame = camera.CFrame end