Hey,
So I’ve been working on a fighting game for around a week now - And there has been this weird glitch happening to me that I don’t entirely know is Roblox’s fault or mine.
The code is simple. I anchor the RootPart, Update its CFrame and unanchor. But the problem is that the rootpart spirals out and basically “offsets” itself from the character.
The client shows everything fine, But the server is having none of it.
Here’s what I mean:
This ends up messing with the physics of the dummy and sends them flying and/or forces them into a ragdoll state.
I don’t want this, and this hasn’t happened with any of my scripts previously. This is the first time this has happened. Can anyone reproduce this?
I haven’t seen any solutions of much help online so I hope someone is able to assist me on this further.
You can’t do this on client and expect it to happen on the server.
Your own character movements will replicate, but cframing someone elses’ character will not replicate to the server.
No no, I know I can’t do this on the client.
This is done within a server script. I’m just showing the client/server view.
The client shows everything fine (Character standing upright, all good)
but the server view shows that the character is tilted for some reason like the root part for some reason just completely offset itself from the main character.
For context, the script is now using PivotTo and pushes the character back while in an animation using BodyVelocity.
I’ve seen nothing wrong with this happening in the past, but it’s become apparent now in this new framework for this fighting game.
The previous framework never had this issue and that used even more deprecated methods than this one - Which was inevitably going to cause issues - But it didn’t.
I’m almost certain this is a Roblox problem at this point.
The issue is about the fact that the dummy offsets within the server view, Which messes with physics, while the client sees it just fine.
Once again, going back to my previous reply, I’m pretty certain it’s purely a Roblox bug at this point. something related to client-server miscommunication.
I did. I did read your post.
And that’s not the point of the post.
I just explained that I’m not anchoring the HRP now, and this isn’t about the actual stun system itself, it’s about the absurd behavior coming from the server side when using what was anchoring, now pivot to, into animation and BodyVelocity to push the enemy away.
I already know how to disable controls and disable movement. I’ve already done that. I don’t need help with that.
This problem seems to only exist on NPCs.
The script goes a bit like this:
--GiveKnockback function, within a ModuleScript being required to the Server
--Function...
--Knockback
--hrpcf is referring to the player's HRP CFrame.
--hitchar is the hit character.
hitchar:PivotTo(hrpcf*CFrame.new(0,0,-3)*CFrame.Angles(0,math.rad(180),0)))
v.MainHandlers.ClassFunctionHandler.ChangeVelocity:Fire(hitchar.HumanoidRootPart.CFrame.LookVector * (knockbackvel or -25),true)
--knockbackvel is given by the serverscript requiring the module
--This is firing to a BindableEvent within the NPC, Giving the velocity and if it's stationary or not (Changing the MaxForce)
--Animation
local s = hit_char:FindFirstChildOfClass("Humanoid"):LoadAnimation(Animation) --Instance Animation is just an animation in ReplicatedStorage.
s.Priority = Enum.AnimationPriority.Action4
s:Play()
s.Stopped:wait()
--Function end
I’m pretty certain there’s nothing wrong with this code, So that’s where I get the suspicion it’s a Roblox issue.
The value hrpcf is being returned from a remote function going to the client to return perfect accuracy with the player when the hitbox is fired - And also to make sure that the other player/npc gets into the correct position for the player hitting.
blame the previous post(s) if you’re questioning why I’m using PivotTo
I’ll try this. Doubt it will do anything though, as the Humanoid literally just routes to the Animator anyway.
literally just a force of habit lol, It won’t change anything if I did or didn’t do it with the capital
I can send you the knockback handler, Which is literally just… What I just sent but messier and with more stuff for customizability.
If you’re a neat coder you’re gonna hate this. Fair warning.
--KnockbackHandler ModuleScript
local module = {}
module.GiveKnockback = function(hit_char: Model,plrchar: Model,plr: Instance,knockbacktype: Instance?,knockbackvel: number,direction:string)
local v = hit_char --This was put here because this was originally in an i,v pairs, but I was too lazy to just... replace all instances of "v"
local char = plrchar
--Knockback
v.Animate.Enabled = false
for i,v in pairs(v.Humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
local hrpcf = char.MainHandlers.ClassKeysHandler.Positions:InvokeClient(plr)
v:PivotTo(hrpcf*CFrame.new(0,0,-3)*CFrame.Angles(0,math.rad(180),0))
task.wait(.01)
if direction == nil or direction == "X" then
v.MainHandlers.ClassFunctionHandler.ChangeVelocity:Fire(v.HumanoidRootPart.CFrame.LookVector * (knockbackvel or -25),true)
elseif direction == "Y" then
v.MainHandlers.ClassFunctionHandler.ChangeVelocity:Fire(Vector3.new(0,(knockbackvel or 25),0),true)
elseif direction == "Z" then
v.MainHandlers.ClassFunctionHandler.ChangeVelocity:Fire(v.HumanoidRootPart.CFrame.RightVector * (knockbackvel or -25),true)
end
task.wait(.1)
v.MainHandlers.ClassFunctionHandler.ChangeVelocity:Fire(Vector3.zero,false)
v:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
v:FindFirstChildOfClass("Humanoid"):SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
--Animations
if knockbacktype == nil then
local s = v:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(game.ReplicatedStorage.KnockbackAnims.HitBack)
s.Priority = Enum.AnimationPriority.Action4
s:Play()
s.Stopped:wait()
else
local s = v:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(knockbacktype)
s.Priority = Enum.AnimationPriority.Action4
s:Play()
s.Stopped:wait()
end
v.Animate.Enabled = true
end
return module
edit: keyboard accidentally pasted it twice, fixed that