I’m trying to make a rush kind of move where you rush foward and if you hit somebody than you grab them. My issue is that when I apply a body velocity to a character’s HumanoidRootPart and then stop it by anchoring the player and deleting the Body Velocity. For some reason the server has a different position for the player than their actual position. But I can’t think of why this would be a thing when none of it is client sided. This becomes a problem because I can’t figure out how to get the player’s actual position.
Simplified Version Of The Script i’m using. (In serverscriptservice being called by a remote function)
local function Rush(Real) -- Real is the Player's Character
local YourHumanoid = Real.Humanoid
local YourHRP = Real.HumanoidRootPart
local Track = YourHumanoid:LoadAnimation(game.ReplicatedStorage.Animations.UniversalAnimations.Rush)
Track:Play()
local Sound = game.ReplicatedStorage.Audio.WhatType:Clone() -- Audio For Rush
Sound.Parent = Real.HumanoidRootPart
Sound:Play()
DS:AddItem(Sound,Sound.TimeLength)
YourHumanoid.WalkSpeed = 0
YourHumanoid.JumpPower = 0
local IF = Instance.new("BoolValue") -- IFrames
IF.Name = "IF"
IF.Parent = Real
local YV = Instance.new("BodyVelocity") -- Your Velocity
YV.MaxForce = Vector3.new(math.huge,0,math.huge)
YV.Velocity = Real.HumanoidRootPart.CFrame.LookVector * 50
YV.Parent = Real.HumanoidRootPart
DS:AddItem(YV,0.5)
-- HitBoxCreation
local Hitbox = Instance.new('Part')
Hitbox.Size = Vector3.new(5,6,5)
Hitbox.BrickColor = BrickColor.new("Really red")
Hitbox.Material = Enum.Material.SmoothPlastic
Hitbox.Name = "HitBox"
Hitbox.CanCollide = false
Hitbox.Anchored = false
Hitbox.Transparency = 0.5
Hitbox.CFrame = Real.HumanoidRootPart.CFrame * CFrame.new(0,0,-3)
Hitbox.Massless = true
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = Real.HumanoidRootPart
Weld.Part1 = Hitbox
Weld.Parent = Real
Hitbox.Parent = YourHumanoid
DS:AddItem(Hitbox,0.5)
DS:AddItem(Weld,0.5)
-- HitBoxCreation
local TargetFound = false -- If a target was found
local Target = "None"
local Over = false -- If move is over
local StunValue = Instance.new("BoolValue") -- A stun value to stop the player from being able to do any moves or punches
StunValue.Name = "StunValue"
StunValue.Parent = Real
DS:AddItem(StunValue,0.5)
Hitbox.Touched:Connect(function(hit)
if TargetFound == false and Over == false then
if hit.Parent then
if hit.Parent:FindFirstChild("Humanoid") then
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
local HRP = hit.Parent:FindFirstChild("HumanoidRootPart")
if Humanoid.Health ~= 0 and not hit.Parent:FindFirstChild("IF") and Humanoid ~= YourHumanoid then -- IFrames
local real = hit.Parent -- Player hit
if not real:FindFirstChild("BlockValue") then -- Checking if their blocking
TargetFound = true
local Amount = 1 -- Stunning the player hit
game.ReplicatedStorage.Stun:FireAllClients(real,Amount) -- Stunning the player hit
YV:Destroy() -- Destroying the velocity
Target = real -- Setting the target to the player hit
print("Rush Hit")
Track:Stop()
local Part = Instance.new("Part")
Part.CFrame = Real.HumanoidRootPart.CFrame -- For testing purposes i'm putting the part at the humanoidrootpart
Part.Anchored = true
Part.CanCollide = false
Part.Parent = Real
IF:Destroy() -- Getting rid of the iframes
end
end
end
end
end
end)
end
What I get when I do it:
Also there is no bug reports or anything in ouput.