You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I am not too familiar with motor6D’s but I have a tween setup where when the player is holding mouse1 on a closet, it will lower their right arm by tweening the viewmodel (stored in the players camera) shoulder motor6D. It works by using a bool value to determine if the players arm should be raised (false) or lowered (true), then playing the tween using that parameter. -
What is the issue?
When my tween is called in studio compared to in game, it looks completely different.
In game: Arm moves in an instant weird position
In studio: Desired effect
-
What solutions have you tried so far?
I looked all over the DevForum and found nothing that would help my problem, I think it may have something to do with loading, but I am not sure.
This is the flashlight module which handles the tween:
CFNew and CFAng are variables for CFrame.new and CFrame.Angles. All the words starting with “VR” belong to the viewport motor6D’s. The tween is also stored in a module script called “UTILITIES.” under a table.
local module = {}
-- Lower the flashlight out of frame
function module.Lower(bool)
if bool then
UTIL["General"].TweenVal(VRShoulder, 0.9, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, {C0 = CFNew(VRShoulderX, VRShoulderY, VRShoulderZ) * CFAng(math.rad(-60), math.rad(-10), 0)})
else
UTIL["General"].TweenVal(VRShoulder, 0.9, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, {C0 = CFNew(VRShoulderX, VRShoulderY, VRShoulderZ) * CFAng(0, 0, 0)})
end
end
return module
This is the local script which uses UserInputService:
local conn1
local eventC
STORAGE.INPUT_SERV.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if mouse.Target then
local target = mouse.Target.Parent
if IsEntity(target, "Closet") and ClosetDetection(target) then
FLASHLIGHT.Lower(true)
conn1 = STORAGE.RUN_SERV.RenderStepped:Connect(function()
local target2
if mouse.Target ~= nil and mouse.Target.Parent:IsA("Model") then
target2 = mouse.Target.Parent
end
if not mouse.Target or target ~= target2 or not ClosetDetection(target) then
eventC:Disconnect()
conn1:Disconnect()
FLASHLIGHT.Lower(false)
end
end)
-- If the player is listening to the closet before it becomes active, ensure they hear when it becomes active
eventC = STORAGE.COLLECT_SERV:GetInstanceAddedSignal("Active"):Connect(function(entity)
if mouse.Target ~= nil and mouse.Target.Parent:IsA("Model") then
local look = mouse.Target.Parent
--print(look.Name, entity.Name)
if look == entity and IsEntity(look, "Closet") then
UTIL["Audio"].FadeAudio(audio.SFX.Entities.Closet.Heartbeat, 1, 0.2, false)
print("Active event")
eventC:Disconnect()
end
return
end
end)
end
end
end
end)
STORAGE.INPUT_SERV.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 and conn1 then
eventC:Disconnect()
conn1:Disconnect()
if mouse.Target then
if mouse.Target ~= nil and mouse.Target.Parent:IsA("Model") then
local target = mouse.Target.Parent
if IsEntity(target, "Closet") then
FLASHLIGHT.Lower(false)
end
end
end
end
end)
If you need anymore information, please don’t be afraid to ask.