This is something I’ve never really had an issue with throughout my years of working on fighting games on Roblox up until recently with this latest project I’m working on, essentially this game (like all the other fighting games I’ve worked on admittedly) uses attacks that create objects used as projectiles to be hurled towards your enemies like bones and whatnot.
The problem with this though is that if I were to be moving backwards while using these attacks (Shiftlock, first person), for some odd reason that I have yet to figure out, the attacks will go wildly off course and just fly off to the left or right rather than straight ahead of the player as it should be going.
The odd thing about this is that, as stated before this has never happened with any of my other fighting games I’ve worked on, even the one I’ve made all the way back in 2020. This game even reuses code from the last fighting game I’ve worked on for it’s attack creation system albeit more optimized, but I do not think the optimizations are what’s causing this because even before that the attacks still behave like this in the game for some reason.
Even stranger is that if I go back to one of those old fighting games and try using an attack while moving backwards, it won’t fly off in some left/right direction?
Here is the code for one of the attack Tools:
active = 1
ogName = script.Parent.Name
script.Parent.Activated:Connect(function()
if active == 1 then
active = 0
local g = game.ServerStorage.attacks["Sans"].Bone:Clone()
g.owner.Value = script.Parent.Parent
g.Parent = workspace
g.PrimaryPart = g.Head
g:PivotTo(script.Parent.Parent["HumanoidRootPart"].CFrame * CFrame.new(0,0,0))
local cd = script.Parent.cd.Value
local origcd = cd
for i = 1,cd do
script.Parent.Name = cd/(script.Parent.division.Value)
task.wait(1/(script.Parent.division.Value))
cd-=1
end
cd = origcd
script.Parent.Name = ogName
active = 1
end
end)
At first I tried changing the Torso from HumanoidRootPart before settling on this change permanently after a friend told me that that would be a more optimized way of handling the attack creation, it didn’t seem to change a thing about what direction the attack goes when moving backwards.
I even took out the Angles part of the PivotTo() code, that didn’t seem to change anything either.
If there is a solution to this, then I do hope it’s something simple like using the Replace All feature in studio or something along the lines of that simplicity because so far I have made like 200+(?) attack Tools for the game and I would go insane manually going through every single one of those, but if it isn’t then I will still try to implement it because I do really want to get this fixed.
Any and all help with this problem will be greatly appreciated, thank you ! ^ ^
-= KNOWN LEADS =-
More information regarding the issue (I am putting this here because I realize it would be more productive to include this in the main post rather than in the replies, my apologies); I have discovered that the attacks do not veer off to the left or right while moving backwards when I am just my unaltered Player model, they also do not do this whenever I am using a traditional morph where you step on a pad.
The attacks do that whenever I am inside of a character model morph stored in a folder inside of ReplicatedStorage, I am able to go into this morph because of a character selection GUI that I had programmed with the help of this YouTube video: https://www.youtube.com/watch?v=UlU80sZSN0g)
Now that I know what specifically is causing this, now I need to figure out how to get it to stop veering the attacks off to the left/right whenever I am inside of this morph because it is crucial that I keep the character selection GUI for the game. I have tried replacing the Noob NPC with a version of my own Player model that had everything non-vital stripped away to put onto the morph pad to then put inside of ReplicatedStorage since I figured the inner workings would be far more accurate than the Noob NPC. Unfortunately this provided the same results as the morph with the Noob NPC as the base.
I’ve also tried doing other various things like copypasting the RootJoint from my Player model to replace the one inside of the morph’s HumanoidRootPart to see if that would change anything, nope.
While I do think I’ve made a huge breakthrough on what’s causing this, I’m still unsure as to how I’m going to be able to fix this as it doesn’t seem to be anything script-wise, the ReplicatedStorage morph itself is barely any different from if I were to just go onto the pad to morph.
The long and short of it: The attacks are going in left/right directions while moving backwards because they are being used while I am inside of a morph from a folder inside ReplicatedStorage after selecting a character on the character selection GUI. I need to figure out what I need to do in order to get the attacks to stop veering off left/right while inside of this morph.
