ive been trying to figure out how to add this 1 detail to this lunging script for the last 2 hours and my brain is tired and i dont know how to do this
ive read 4 devforum posts, and the entire tool document, and i got nada!!
script:
function Lunge()
Damage = DamageValues.LungeDamage
print(Tool.Grip.RightVector)
Tool.Grip = CFrame.new(script.Parent["Right Arm"] - 0) --how to orient the X of the grip by 90 degrees pls help
print(Tool.Grip.RightVector)
Tool.Handle.SwordLunge:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Lunge")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
Tool.Grip:ToOrientation(Tool.Grip + UDim2.new(0,0,0, -90, 0, 0))
--Tool.Handle.CFrame.Orientation = Vector3.new(0, 90, 90) --:ToOrientation(0, 90, 90)
end
end
I’m not sure what you’re trying to do exactly, but there is a tool grip editor plugin out there for this, I think it cost like 5 robux, or something.
If you don’t have robux, or you’re trying to modify the tool grip by a certain angle, just use CFrame.Angles(), multiply that by the current tool grip, and the grip will change by the values provided (radians).
If I wanted to rotate the X of the grip by 90 degrees, I would say:
tool.Grip *= CFrame.Angles(math.rad / 2, 0, 0)
This is because math.pi is 180 degrees in radians, so you would divide by 2.
local pathfindingservice = game:GetService("PathfindingService")
local enemy = script.Parent
enemy.Name = "Guest_"..math.random(1,100000)
local Humanoid = enemy.Humanoid
local torso = enemy.Torso
local Tool = script.Parent.ClassicSword
local DamageValues = script.Parent.Configuration
waittime = 0.1
local Damage = 5
local debounce = false
function Attack()
Damage = DamageValues.SlashDamage
Tool.Handle.SwordSlash:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Slash")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end
end
function Lunge()
Damage = DamageValues.LungeDamage
print(Tool.Grip.RightVector)
Tool.Grip *= CFrame.Angles(math.rad(math.pi) / 2, 0, 0) --how to orient the X of the grip by 90 degrees pls help
print(Tool.Grip.RightVector)
Tool.Handle.SwordLunge:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Lunge")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
Tool.Grip *= CFrame.Angles(0 - math.rad(math.pi) / 2, 0, 0)
--Tool.Handle.CFrame.Orientation = Vector3.new(0, 90, 90) --:ToOrientation(0, 90, 90)
end
end
local function getnearestplayer()
repeat wait() until #game.Players:GetPlayers() > 0
local players = game.Players:GetPlayers()
local bestdist = (game.Workspace["Classic Statue"].Statue.Torso.Position - torso.Position).Magnitude
local nearestplayer = game.Workspace["Classic Statue"].Statue
for _,player in pairs(players) do
local character = player.Character
local chartorso = character:WaitForChild("Torso")
local distance = (chartorso.Position - torso.Position).Magnitude
if distance < bestdist then
bestdist = distance
nearestplayer = player
end
end
local walls = game.Workspace.Builds:GetChildren()
for _,wall in pairs(walls) do
local distance = (wall.HumanoidRootPart.Position - torso.Position).Magnitude
if distance < bestdist then
bestdist = distance
nearestplayer = wall
end
end
return nearestplayer,bestdist
end
while wait(waittime) do
local path = pathfindingservice:CreatePath()
local nearestplr, nearestdist = getnearestplayer()
if nearestplr ~= workspace["Classic Statue"].Statue and nearestplr.Parent ~= workspace.Builds then
path:ComputeAsync(torso.Position,nearestplr.Character.Torso.Position)
else
if nearestplr.Parent ~= workspace.Builds then
path:ComputeAsync(torso.Position,nearestplr.Torso.Position)
else
path:ComputeAsync(torso.Position,nearestplr.HumanoidRootPart.Position)
end
end
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump and Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall --[["FallingDown"]] then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
if --[[nearestdist < 4 and]] debounce == false then
task.spawn(function()
Lunge()
local partsinhandle = workspace:GetPartsInPart(Tool.Handle)
print(partsinhandle)
for _,hit in pairs(partsinhandle) do
if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent.Parent ~= game.Workspace.Enemies and hit.Parent.Parent.Parent ~= game.Workspace.Enemies and debounce == false then
hit.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(15)
end
end
debounce = true
wait(1)
debounce = false
end)
end
Humanoid:MoveTo(waypoint.Position)
end
end
still doesnt work. i changed the orientation of the sword using the server manually and it changed, also i just now realized i have to switch the grip of the sword to 0,-180,90 to get the effect im trying to get. even after adjusting the script for it it still doesnt orient
added prints, everything happens when it should happen, except the happening part
changed the lunge function a little bit
output of the prints
local pathfindingservice = game:GetService("PathfindingService")
local enemy = script.Parent
enemy.Name = "Guest_"..math.random(1,100000)
local Humanoid = enemy.Humanoid
local torso = enemy.Torso
local Tool = script.Parent.ClassicSword
local DamageValues = script.Parent.Configuration
waittime = 0.1
local Damage = 5
local debounce = false
function Attack()
Damage = DamageValues.SlashDamage
Tool.Handle.SwordSlash:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Slash"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Slash")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
end
end
function Lunge()
Damage = DamageValues.LungeDamage
print("grip should initially be changed now")
Tool.Grip *= CFrame.Angles(0, math.pi, 0) --how to orient the X of the grip by 90 degrees pls help
Tool.Handle.SwordLunge:Play()
if Humanoid then
if Humanoid.RigType == Enum.HumanoidRigType.R6 then
print("i know youre r6")
local Anim = Instance.new("StringValue")
Anim.Name = "toolanim"
Anim.Value = "Lunge"
Anim.Parent = Tool
elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
local Anim = Tool:FindFirstChild("R15Lunge")
if Anim then
local Track = Humanoid:LoadAnimation(Anim)
Track:Play(0)
end
end
wait(1)
print("grip reverted")
Tool.Grip *= CFrame.Angles(0, 0 - math.pi, 0)
--Tool.Handle.CFrame.Orientation = Vector3.new(0, 90, 90) --:ToOrientation(0, 90, 90)
end
end
local function getnearestplayer()
repeat wait() until #game.Players:GetPlayers() > 0
local players = game.Players:GetPlayers()
local bestdist = (game.Workspace["Classic Statue"].Statue.Torso.Position - torso.Position).Magnitude
local nearestplayer = game.Workspace["Classic Statue"].Statue
for _,player in pairs(players) do
local character = player.Character
local chartorso = character:WaitForChild("Torso")
local distance = (chartorso.Position - torso.Position).Magnitude
if distance < bestdist then
bestdist = distance
nearestplayer = player
end
end
local walls = game.Workspace.Builds:GetChildren()
for _,wall in pairs(walls) do
local distance = (wall.HumanoidRootPart.Position - torso.Position).Magnitude
if distance < bestdist then
bestdist = distance
nearestplayer = wall
end
end
return nearestplayer,bestdist
end
while wait(waittime) do
local path = pathfindingservice:CreatePath()
local nearestplr, nearestdist = getnearestplayer()
if nearestplr ~= workspace["Classic Statue"].Statue and nearestplr.Parent ~= workspace.Builds then
path:ComputeAsync(torso.Position,nearestplr.Character.Torso.Position)
else
if nearestplr.Parent ~= workspace.Builds then
path:ComputeAsync(torso.Position,nearestplr.Torso.Position)
else
path:ComputeAsync(torso.Position,nearestplr.HumanoidRootPart.Position)
end
end
local waypoints = path:GetWaypoints()
for i, waypoint in pairs(waypoints) do
if waypoint.Action == Enum.PathWaypointAction.Jump and Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping and Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall --[["FallingDown"]] then
Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end
if --[[nearestdist < 4 and]] debounce == false then
debounce = true
task.spawn(function()
Lunge()
local partsinhandle = workspace:GetPartsInPart(Tool.Handle)
print(partsinhandle)
for _,hit in pairs(partsinhandle) do
if hit.Parent:FindFirstChildOfClass("Humanoid") and hit.Parent.Parent ~= game.Workspace.Enemies and hit.Parent.Parent.Parent ~= game.Workspace.Enemies and debounce == false then
hit.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(15)
end
end
wait(1)
debounce = false
end)
end
Humanoid:MoveTo(waypoint.Position)
end
end
You’re using the default swords? I didn’t even know, if you would have told me I could have helped. The reason why is because the sword script changes the grip at run time, so you have to edit the grips in the script, you don’t have to do this.