Exoiryx
(Exoiryx)
May 27, 2023, 3:11am
#1
I need the player to face the mouse when they charge up their move but when they do, they shake around and move instead of just staying still.
heres my code
event.OnServerEvent:Connect(function(plr, hit)
local vel = Instance.new("BodyVelocity")
vel.MaxForce = Vector3.new(0,999999,0)
vel.Velocity = Vector3.new(0,0,0)
vel.Parent = plr.Character.HumanoidRootPart
plr.Character.HumanoidRootPart.CFrame =
CFrame.new(plr.Character.HumanoidRootPart.Position, hit)
wait(2)
vel:Remove()
end)
1 Like
Use a BodyGyro to rotate the character, and use the BodyVelocity to keep the character in place
Exoiryx
(Exoiryx)
May 27, 2023, 5:23am
#3
how would I use body gyro? I’ve never used stuff like this
RaidyQK
(RaidyQK)
May 27, 2023, 7:29am
#4
Personally, I don’t think this is bad. If u add some sfx that represent a charge, the shake may be actually benefic for the gamefeel. It adds some immersivity and empowers the idea that the character is charging their power.
Exoiryx
(Exoiryx)
May 27, 2023, 8:08am
#5
its just a bit too hard to aim though
(there’s sounds I just have roblox turned down lol)
RaidyQK
(RaidyQK)
May 27, 2023, 8:10am
#6
I think being hard to aim is good. I mean, what if 2 teamers spam the same person. A fully charged ranged attack should not be an insta kill. This also implies the requirement of skill.
Exoiryx
(Exoiryx)
May 27, 2023, 8:51am
#7
yea but its a PVE game and thats the ultimate
1 Like
BodyGyro applies a rotational force to whatever it’s parented to
In your case you would do:
event.OnServerEvent:Connect(function(plr, hit)
local Character = plr.Character
local RootPart = Character.HumanoidRootPart
local vel = Instance.new("BodyVelocity")
vel.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
vel.Velocity = Vector3.zero
vel.Parent = RootPart
local gyro = Instance.new("BodyGyro")
gyro.MaxTorque = Vector3.new(400000, 400000, 400000)
gyro.D = 350
gyro.P = 30000
gyro.Parent = RootPart
gyro.CFrame = CFrame.new(RootPart.Position, hit)
task.delay(2, function()
vel:Destroy()
gyro:Destroy()
end)
end)
It’s also worth noting you should be managing all movement on the client, and not relying on the server to tell the client where & how to move