Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Apr 2013 02:50 PM |
| So i made a simple raycasting script and it works the first time, but when i die it doesen't do anything, why? |
|
|
| Report Abuse |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Apr 2013 02:51 PM |
It shoots from my torso to where i click, oh and heres the script btw:
tool = script.Parent me = game.Players.LocalPlayer.Character
tool.Selected:connect(function(mouse) mouse.Button1Down:connect(function()
ray = Ray.new(me.Torso.CFrame.p, (mouse.Hit.p - me.Torso.CFrame.p ).unit*300) ObjectRayHit,RayHitPosition = game.Workspace:FindPartOnRay(ray,me)
if ObjectRayHit and ObjectRayHit.Parent and ObjectRayHit:findFirstChild("Humanoid") then ObjectRayHit.Humanoid:TakeDamage(25) end
distance = (me.Torso.CFrame.p - RayHitPosition).magnitude b = Instance.new("Part", me) b.Name = "RayPart" b.BrickColor = BrickColor.new("Bright red") b.Anchored = true b.CanCollide = false b.TopSurface = "Smooth" b.BottomSurface = "Smooth" b.Size = Vector3.new(1, 1, distance) b.CFrame = CFrame.new(RayHitPosition, me.Torso.CFrame.p) * CFrame.new(0,0,-distance/2)
game:GetService("Debris"):AddItem(b, 1) end) end) |
|
|
| Report Abuse |
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 30 Apr 2013 03:24 PM |
me = game.Players.LocalPlayer.Character
That's why it doesn't work if you reset. I think this should work:
game.Players.LocalPlayer.CharacterAdded:wait() me = game.Players.LocalPlayer.Character |
|
|
| Report Abuse |
|