I want a player’s humanoid root part to be moved +10 on the Z-Axis. I sadly cannot find a method on how to tween it. I can teleport the position just fine, but I’d like it to be smooth. Can’t find any tutorials.
My working code:
local rs = game:GetService("ReplicatedStorage")
local damageevent1 = rs:WaitForChild("DamageEvent1")
damageevent1.OnServerEvent:Connect(function(player, v)
v.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0)
v.Parent:WaitForChild("HumanoidRootPart").Position += Vector3.new(0,0,10)
end)
The code that I want to work:
local rs = game:GetService("ReplicatedStorage")
local damageevent1 = rs:WaitForChild("DamageEvent1")
damageevent1.OnServerEvent:Connect(function(player, v)
v.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(0.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut, 0, false, 0)
TS:Create(v.Parent, Info, {Position = v.Parent:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,0,10)}):Play()
end)
Just change this line TS:Create(v.Parent, Info, {Position = v.Parent:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,0,10)}):Play()
To this TS:Create(v.Parent:WaitForChild("HumanoidRootPart") Info, {Position = v.Parent:WaitForChild("HumanoidRootPart").Position + Vector3.new(0,0,10)}):Play()
Why:
The first argument in the tweenservice:create is the instance that you are tweening and v.Parent does not seem to be the HRP
The Tween should be controlled by the Client, and then Applied to the Server once its Done, this is to Avoid Unnessacary Issues with the Server, Movement should Automatically Replicate to the Server (If Object is Owned by a Player or Player’s Character), and to have a more Smoother Animation.
Also, if you plan to move the HumanoidRootPart, use CFrame instead of Vector3 as changing the Position (A Vector3 Value) will just only move the HumanoidRootPart and not the Rest of the Model.
When doing this you should also anchor the HumanoidRootPart to avoid Physics, as that can Disrupt the Tweening Process.
Also, you forgot to add a Comma between your Instance, and your TweenInfo.
Thank you very much! While you’re here, do you know of any way to match the direction of movement to the direction of another players’ camera? Once again, thank you. I also would like an idea of how to apply my effects to the server once it’s done.
You would have to grab that Data from the Other Client (Other Player), and then Send it to the Server, and then back to the Clients, for you to use, this can be done using a RemoteEvent which allows you to send data across the Server/Client Boundary.
You know when you take knockback while in fighting game, and the direction of the player attacking you determines which direction you will fly away towards? Basically that.