I have a gun and I’m making aiming based on offset value in viewmodel, my math is wrong when holding mb2d here’s script when holding mouse buton 2
local AimPosition = Parent:WaitForChild("ToolModel"):WaitForChild("AimPosition")
Mouse.Button2Down:Connect(function()
aimoffset = Camera.CFrame:ToObjectSpace(AimPosition.CFrame):Inverse()
Button2Down = true
end)
game:GetService("RunService").RenderStepped:Connect(function()
if Button2Down then
offset = aimoffset:Inverse()
else
offset = CFrame.new(0,0,0)*CFrame.fromEulerAnglesXYZ(0,0,0)
end
local o = Player.PlayerScripts.Viewmodel.Offset0
o.Value = aimoffset
end)
as you seeing here, when aiming it is soo wrong
now it’s randomly working it’s probably goiung to break later
it broke
it works randomly and not always
im having the same prob howd u fix it
idk it’s breeaking half the time
I still have this problem, whenever the value is wrong it goes to the hundreds, it’s just not supposed to. It’s a simple offset and I do inverse the aiming cframe. Here:
Mouse.Button2Down:Connect(function()
aimoffset = Camera.CFrame:ToObjectSpace(AimPosition.CFrame):Inverse()
Button2Down = true
end)
Mouse.Button2Up:Connect(function()
aimoffset = CFrame.new(0,0,0)
Button2Down = false
end)
game:GetService("RunService").RenderStepped:Connect(function()
local o = Player.PlayerScripts.Viewmodel.Offset0
o.Value=o.Value:Lerp(aimoffset,.5)
end)
outputted aimoffset wrong value:
-3.25339508, -144.542847, -61.8276405, 0.63593477, 0.492483675, -0.594177544, 0, 0.769916475, 0.638144791, 0.771742821, -0.405818462, 0.489616632 : aimoffset
1 Like