phoniex
|
  |
| Joined: 03 Feb 2008 |
| Total Posts: 34985 |
|
|
| 24 Sep 2015 06:01 PM |
This script gets this error at line 14. How do I fix it?
#code local tool = script.Parent local user local IgnoreList = {"Handle", "Hat"}
tool.Equipped:connect(function(mouse) user = tool.Parent
mouse.Button1Down:connect(function() local ray = Ray.new(tool.AimPart.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray,{"Handle"})
local playerhit = game.Players:GetPlayerFromCharacter(hit.Parent) or game.Players:GetPlayerFromCharacter(hit.Parent.Parent) if playerhit then local humanoid = playerhit.Character.Humanoid print(hit.Name) if humanoid then if hit.Name == "Head" then humanoid:TakeDamage(100) else humanoid:TakeDamage(30) end end
-- Settings local distance = (position - tool.AimPart.CFrame.p).magnitude local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Really blue") rayPart.Parent = game.Workspace rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, tool.AimPart.CFrame.p) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(rayPart, 0.1) end end) end)
http://www.roblox.com/item.aspx?id=147357900 http://www.roblox.com/e-item?id=289672302 |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2015 06:01 PM |
| I means it wanted an Instance, and you gave it another type of value. |
|
|
| Report Abuse |
|
|
phoniex
|
  |
| Joined: 03 Feb 2008 |
| Total Posts: 34985 |
|
|
| 24 Sep 2015 06:04 PM |
@Jarod
The purpose of the table part is to ignore Handles. Is there a way to do this?
http://www.roblox.com/item.aspx?id=147357900 http://www.roblox.com/e-item?id=289672302 |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2015 06:04 PM |
And I have no idea where the error is, since you only said "Line 14" which I have no idea about, but this is probably it. "Handle" It takes Instances, not strings. |
|
|
| Report Abuse |
|
|
|
| 24 Sep 2015 06:16 PM |
Here, I worked up something to help with this.
local CastRay CastRay = function(Origin, Direction, Distance, IgnoreList, IgnoreFunction) local LeftOverDistance = 0 while Distance > 1000 do LeftOverDistance = LeftOverDistance + 1000 Distance = Distance - 1000 end local Hit, Pos, Surface = workspace:FindPartOnRay(Ray.new(Origin, Direction.Unit*Distance), IgnoreList, false) if Hit then if IgnoreFunction and IgnoreFunction(Hit) then table.insert(IgnoreList, Hit) return CastRay(Pos, Direction, LeftOverDistance + (Distance-(Origin-Pos).Magnitude), IgnoreList, IgnoreFunction) end end if LeftOverDistance > 0 then return CastRay(Pos, Direction, LeftOverDistance, IgnoreList, IgnoreFunction) end return Hit, Pos, Surface end Now just copy it, and use it like this: local Hit, Pos = CastRay(tool.AimPart.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit, 300, {}, function(Part) if Part.Name == "Handle" then return true end end) |
|
|
| Report Abuse |
|
|
phoniex
|
  |
| Joined: 03 Feb 2008 |
| Total Posts: 34985 |
|
|
| 24 Sep 2015 06:18 PM |
@Jarod
Where should I put those blocks of code, exactly?
http://www.roblox.com/item.aspx?id=147357900 http://www.roblox.com/e-item?id=289672302 |
|
|
| Report Abuse |
|
|