- What do you want to achieve? Make a flashlight tool which looks nice in my hand (lags pleasantlywhen I suddenly move). Here is the script I used:
local p = script.Parent; -- Handle, which is a meshpart
local t = p.Parent; -- Tool
local char = game.Players.LocalPlayer.Character;
local rh = char:FindFirstChild("RightHand") or char:FindFirstChild("RightArm")
rh.DescendantAdded:Connect(function(d)
if d.Name == "RightGrip" then
d:Destroy()
end
end)
local lcp = Vector3.new()
game:GetService("RunService").RenderStepped:Connect(function(dt)
local cammov = workspace.CurrentCamera.CFrame.Position-lcp
p.Position += cammov*0.9 -- Make movement lag less intense
local targetcf = workspace.CurrentCamera.CFrame*CFrame.new(1,-1,-2)
p.CFrame = p.CFrame:Lerp(targetcf, 1 - math.exp(-10 * dt))
lcp = workspace.CurrentCamera.CFrame.Position
end)
-
What is the issue? Whenever the flashlight mesh’s center is not onscreen, the entire mesh stops rendering
-
What solutions have you tried so far? I’ve tried adding a highlight, putting it inside a regular part, etc. None of these have worked. I think the problem might be with the fact that it’s a tool, not the fact that I’m using meshparts