|
| 13 Jul 2015 01:55 PM |
I find people often making team fortress scripts and asking for backstab scripts i know i could have used math.acos and :Dot() function but i did not want to have to use degrees.
function dotProduct(a,b) return a.x*b.x+a.y*b.y+a.z*b.z --search it up end
tool=script.Parent sword=tool.Handle; sword.Touched:connect(function(hit) if hit.Parent ~= tool.Parent then humanoid=hit.Parent:findFirstChild("Humanoid") vCharacter=tool.Parent TorsoPos=hit.Parent.Torso.Position --the torso of the guy you're about kill vTorsoPos=vCharacter.Torso.Position --your torso Player=Game.Players:GetPlayerFromCharacter(hit.Parent) vPlayer=Game.Players:GetPlayerFromCharacter(vCharacter) if Player.TeamColor ~= vPlayer.TeamColor then end humanoid.Died:connect(function() local distance=vTorsoPos-TorsoPos local normDistance=distance/distance.magnitude local dp=dotProduct(normDistance,humanoid.Torso.CFrame.lookVector) print(dp) if dp < -0.2665 then --[[ increase the value to local m=Instance.new("Message") increase the range of a m.Parent=game.Workspace backstab as long as the value m.Text="BACKSTAB!!!" is not 0 or greater than 0 wait(2) you should be fine --]] m:Destroy() end end) end end)
|
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 13 Jul 2015 01:56 PM |
| Apart from the fact this won't always work |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Jul 2015 02:23 PM |
| It may not be completely perfect but it's close enough |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 13 Jul 2015 02:34 PM |
| I'm gonna guess this is a free model because of how bad it is. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2015 02:35 PM |
No its not a free model
--classic robloxians need to stop bashing |
|
|
| Report Abuse |
|
|