Code:
Server:
local neck_snap_event = script.Parent.neck_snap
local config = require(script.Parent.config)
local tweenservice = game:GetService("TweenService")
local last_time = tick()
neck_snap_event.OnServerEvent:Connect(function(player,target)
if target == player.Character then return end
if tick()-last_time<=config.cooldown then return end
last_time=tick()
local Distance = (player.Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if Distance <= config.distance then
local tween2 = tweenservice:Create(player.Character.Head.Neck,TweenInfo.new(.2,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,true),{C1 = target.Head.Neck.C1 * CFrame.Angles(0,-.3,-.3)})
tween2:Play()
task.spawn(function()
local tween = tweenservice:Create(target.Head.Neck,TweenInfo.new(.1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out),{C1 = target.Head.Neck.C1 * CFrame.Angles(0,180,0)})
tween:Play()
tween.Completed:Connect(function()
target.Humanoid:TakeDamage(config.damage)
script.Parent.shake_camera:FireClient(player)
if game.Players:GetPlayerFromCharacter(target) then
script.Parent.shake_camera:FireClient(game.Players:GetPlayerFromCharacter(target))
end
end)
end)
end
end)
Client:
local neck_snap_tool = script.Parent
local neck_snap_event = neck_snap_tool:WaitForChild("neck_snap")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local config = require(neck_snap_tool.config)
local camera_shaker = require(game.ReplicatedStorage.modules.CameraShaker)
local camera = workspace.CurrentCamera
function shake()
local cam_shake = camera_shaker.new(Enum.RenderPriority.Camera.Value, function(shakeCf)
camera.CFrame = camera.CFrame * shakeCf
end)
cam_shake:Start()
cam_shake:Shake(camera_shaker.Presets.Explosion)
wait(.2)
cam_shake:Stop()
end
local last_time = tick()
UIS.InputBegan:Connect(function(input,is_typing)
if is_typing then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode~=Enum.KeyCode.E then return end
if mouse == nil then return end
if mouse.Target.Parent:FindFirstChild("Humanoid") then
if tick()-last_time<config.cooldown then return end
local target = mouse.Target.Parent
local Distance = (player.Character.HumanoidRootPart.Position - target.HumanoidRootPart.Position).Magnitude
if Distance <= config.distance then
neck_snap_event:FireServer(target)
end
end
end
end)
neck_snap_tool.shake_camera.OnClientEvent:Connect(shake)
So my issue is: the player’s head (not the target’s) is being rotated quite inconsistently. video
It only works properly if line 21 in the server is commented tween:Play(). video
The two tweens seem completely unrelated, I have no clue why this would happen.
I’ve tried searching for other people with a similar issue but couldn’t find any. If you have any questions about the context or something else please make sure to let me know.
Thank you and have a wonderful day!