Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local bullet = script.Bullet
- bullet.Parent = nil
- local tab = {}
- script.Parent.Trigger.Touched:Connect(function(prt)
- if prt.Parent and prt.Parent:FindFirstChildOfClass("Humanoid") and prt.Parent:FindFirstChild("HumanoidRootPart") and not tab[prt.Parent] then
- coroutine.resume(coroutine.create(function()
- tab[prt.Parent] = true;
- while true do
- wait(0.5)
- if prt.Parent:FindFirstChild("HumanoidRootPart") and prt.Parent:FindFirstChildOfClass("Humanoid") and prt.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
- if (prt.Parent:FindFirstChild("HumanoidRootPart").Position-script.Parent.Main.Position).magnitude > 35 then
- break;
- end
- script.Parent.Main.CFrame = CFrame.new(script.Parent.Main.Position,prt.Parent:FindFirstChild("HumanoidRootPart").Position)
- local newbullet = bullet:Clone()
- newbullet.CFrame = script.Parent.Barrel.ShotPoint.WorldCFrame;
- Instance.new("BodyVelocity",newbullet).Velocity = script.Parent.Main.CFrame.LookVector*200;
- newbullet.Touched:connect(function(prta)
- if prta.Parent and prta.Parent:FindFirstChildOfClass("Humanoid") then
- prta.Parent:FindFirstChildOfClass("Humanoid"):TakeDamage(25);
- newbullet:Destroy();
- end
- end)
- game:GetService("Debris"):AddItem(newbullet,20);
- newbullet.Parent = workspace
- else
- break;
- end
- end
- tab[prt.Parent] = false
- end))
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment