How do i fix the wield of a tool?
I recently wanted to add some swords to my game and i have come across this issue:
https://gyazo.com/e52392c16e4aed4f8f2dd5f863ac945d
Do i have to just change the rotation of the tool?
Here's my current sword script:
001 | r = game:service( "RunService" ) |
007 | local slash_damage = 12 |
008 | local lunge_damage = 31 |
010 | sword = script.Parent.Handle |
014 | local SlashSound = Instance.new( "Sound" ) |
016 | SlashSound.Parent = sword |
017 | SlashSound.Volume = . 7 |
019 | local LungeSound = Instance.new( "Sound" ) |
021 | LungeSound.Parent = sword |
022 | LungeSound.Volume = . 6 |
024 | local UnsheathSound = Instance.new( "Sound" ) |
026 | UnsheathSound.Parent = sword |
027 | UnsheathSound.Volume = 1 |
031 | if (hit.Parent = = nil ) then return end |
033 | local humanoid = hit.Parent:findFirstChild( "Humanoid" ) |
034 | local vCharacter = Tool.Parent |
035 | local vPlayer = game.Players:playerFromCharacter(vCharacter) |
036 | local hum = vCharacter:findFirstChild( "Humanoid" ) |
037 | if humanoid and humanoid ~ = hum and hum then |
039 | local guygettingsliced = game.Players:GetPlayerFromCharacter(hit.Parent) |
040 | local right_arm = vCharacter:FindFirstChild( "Right Arm" ) |
042 | local joint = right_arm:FindFirstChild( "RightGrip" ) |
043 | if (joint and (joint.Part 0 = = sword or joint.Part 1 = = sword)) then |
044 | if guygettingsliced then |
046 | tagHumanoid(humanoid, vPlayer) |
047 | humanoid:TakeDamage(damage) |
049 | untagHumanoid(humanoid) |
052 | tagHumanoid(humanoid, vPlayer) |
053 | humanoid:TakeDamage(damage) |
055 | untagHumanoid(humanoid) |
058 | if (right_arm ~ = nil ) then |
059 | local joint = right_arm:FindFirstChild( "RightGrip" ) |
060 | if (joint ~ = nil and (joint.Part 0 = = sword or joint.Part 1 = = sword)) then |
061 | tagHumanoid(humanoid, vPlayer) |
062 | if game.Players:FindFirstChild(hit.Parent.Name) then |
063 | local Victim = game.Players:GetPlayerFromCharacter(hit.Parent) |
064 | if Victim:FindFirstChild( 'Duelling' ) then |
066 | if not vCharacter:FindFirstChild( 'RK' ) then |
067 | local TaggedasRk = Instance.new( 'StringValue' , vCharacter) |
068 | TaggedasRk.Name = "RK" |
069 | TaggedasRk.Value = vPlayer.Name |
073 | if hit.Parent.Name = = "Sword bot" then |
074 | if not vCharacter:FindFirstChild( 'RK' ) then |
075 | local TaggedasRk = Instance.new( 'StringValue' , vCharacter) |
076 | TaggedasRk.Name = "RK" |
077 | TaggedasRk.Value = vPlayer.Name |
080 | humanoid:TakeDamage(damage) |
082 | untagHumanoid(humanoid) |
093 | function tagHumanoid(humanoid, player) |
094 | local creator_tag = Instance.new( "ObjectValue" ) |
095 | creator_tag.Value = player |
096 | creator_tag.Name = "creator" |
097 | creator_tag.Parent = humanoid |
100 | function untagHumanoid(humanoid) |
101 | if humanoid ~ = nil then |
102 | local tag = humanoid:findFirstChild( "creator" ) |
111 | damage = slash_damage |
113 | local anim = Instance.new( "StringValue" ) |
114 | anim.Name = "toolanim" |
120 | damage = lunge_damage |
124 | local anim = Instance.new( "StringValue" ) |
125 | anim.Name = "toolanim" |
130 | local force = Instance.new( "BodyVelocity" ) |
131 | force.velocity = Vector 3. new( 0 , 10 , 0 ) |
132 | force.maxForce = Vector 3. new( 0 , 4000 , 0 ) |
133 | force.Parent = Tool.Parent.Torso |
141 | damage = slash_damage |
145 | Tool.GripForward = Vector 3. new( 1 , 0 , 0 ) |
146 | Tool.GripRight = Vector 3. new( 0 , 0 , - 1 ) |
147 | Tool.GripUp = Vector 3. new( 0 , - 1 , 0 ) |
151 | Tool.GripForward = Vector 3. new( 1 , 0 , 0 ) |
152 | Tool.GripRight = Vector 3. new( 0 , 0 , - 1 ) |
153 | Tool.GripUp = Vector 3. new(- 20 , - 1 , 0 ) |
156 | function swordAcross() |
163 | function onActivated() |
165 | if not Tool.Enabled then |
171 | local character = Tool.Parent; |
172 | local humanoid = character.Humanoid |
173 | if humanoid = = nil then |
174 | print ( "Humanoid not found" ) |
178 | local t = r.Stepped:wait() |
180 | if (t - last_attack < . 2 ) then |
199 | script.Parent.Activated:connect(onActivated) |
200 | script.Parent.Equipped:connect(onEquipped) |
203 | connection = sword.Touched:connect(blow) |