Ok so I have a FE compatible slingshot but the pellets are launching the wrong way when I click, here are the scripts:
01 local debris = game:service("Debris") 02 pellet = script.Parent 03 damage = 8 04
05 function tagHumanoid(humanoid) 06 local tag = pellet:findFirstChild("creator") 07 if tag ~= nil then 08 while(humanoid:findFirstChild("creator") ~= nil) do 09 humanoid:findFirstChild("creator").Parent = nil 10 end 11
12 local new_tag = tag:clone() 13 new_tag.Parent = humanoid 14 debris:AddItem(new_tag, 1) 15 end View all 55 lines... Tool = script.Parent VELOCITY = 85
local Pellet = Instance.new("Part") Pellet.Locked = true Pellet.BottomSurface = 0 Pellet.TopSurface = 0 Pellet.Shape = 0 Pellet.Size = Vector3.new(1,1,1) Pellet.BrickColor = BrickColor.new(2)
Tool.PelletScript:clone().Parent = Pellet
function spawnSound(sound) local s = sound:clone() s.Parent = sound.Parent s:Play() s.Ended:connect(function () s:Destroy() end) end
function fire(mouse_pos)
01 spawnSound(Tool.Handle.SlingshotSound) 02
03 local vCharacter = Tool.Parent 04 local vPlayer = game.Players:playerFromCharacter(vCharacter) 05
06 local head = vCharacter:findFirstChild("Head") 07 if head == nil then return end 08
09 local dir = mouse_pos - head.Position 10 dir = computeDirection(dir) 11
12 local launch = head.Position + 5 * dir 13
14 local delta = mouse_pos - launch 15
View all 50 lines... end
function computeLaunchAngle(dx,dy,grav)
01 local g = math.abs(grav) 02 local inRoot = (VELOCITYVELOCITYVELOCITYVELOCITY) - (g * ((gdxdx) + (2dyVELOCITYVELOCITY))) 03 if inRoot <= 0 then 04 return .25 * math.pi 05 end 06 local root = math.sqrt(inRoot) 07 local inATan1 = ((VELOCITYVELOCITY) + root) / (gdx) 08
09 local inATan2 = ((VELOCITYVELOCITY) - root) / (gdx) 10 local answer1 = math.atan(inATan1) 11 local answer2 = math.atan(inATan2) 12 if answer1 < answer2 then return answer1 end 13 return answer2 end
function computeDirection(vec) local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) return Vector3.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt) end
Tool.Enabled = true function onActivated()
01 if not Tool.Enabled then 02 return 03 end 04
05 Tool.Enabled = false 06
07 local character = Tool.Parent; 08 local humanoid = character.Humanoid 09 if humanoid == nil then 10 print("Humanoid not found") 11 return 12 end 13
14 if humanoid.Health <= 0 then 15 return View all 24 lines... end
script.Parent.Activated:connect(onActivated)