KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
ill give you the two lines of code that i you need.
RayIgnore = {script.Parent,script.Parent.Parent}--tool,character
hit,position = Game.Workspace:FindPartOnRayWithIgnoreList(ray,Settings.RayIgnore)
Im still hitting the gun handle and the character. HOW?!?!?
|
|
BruceAB12Join Date: 2012-01-19 Post Count: 3238 |
|
|
|
The first thing I notice here is that there is no reason to ignore both the tool and the character because if you just ignore the character then it will also ignore all its descendants and the tool is one of them.
The second thing is you declare the table as RayIgnore, but when you call the FindPartOnRayWithIgnoreList method you use another table named Settings.RayIgnore
So this should work:
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, script.Parent.Parent) |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
"The first thing I notice here is that there is no reason to ignore both the tool and the character because if you just ignore the character then it will also ignore all its descendants and the tool is one of them."
Sorry its late by me and i dont think. Thanks for putting up with my stupity.
|
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
its unable to cast value to objects. |
|
BruceAB12Join Date: 2012-01-19 Post Count: 3238 |
Ignore my post lol.
Keep it simple. |
|
|
Can you post the full script? |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
sure but its 60 lines. |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
Tool = script.Parent
Handle = Tool.Handle
Player = Game.Players.LocalPlayer
Settings = {
--GUN--
Damage = {10,30};
Range = 100;
MaxAmmo = 10;
ReloadTime = 2;
--OTHER--
HumanoidName = "Humanoid";
TeamKill = false;
RayIgnore = {script.Parent,script.Parent.Parent}--tool,character
}
function Fire()
Character = Player.Character
Humanoid = Character.Humanoid
TargetPos = Humanoid.TargetPoint
Direction = (TargetPos - Character.Head.Position).unit
ray = Ray.new(Character.Head.Position,Direction*Settings.Range)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, script.Parent.Parent)
distance = ((position - Tool.Handle.Position).magnitude)
lazer = Instance.new("Part",Game.Workspace)
lazer.Anchored = true
lazer.BrickColor = Player.TeamColor
lazer.Transparency = 0.5
lazer.BottomSurface = "Smooth"
lazer.TopSurface = "Smooth"
lazer.CanCollide = false
lazer.FormFactor = "Custom"
lazer.Size = Vector3.new(0.2,0.2,distance)
lazer.CFrame = CFrame.new(position,Tool.Handle.Position) * CFrame.new(0,0,-distance/2)
s2 = script.RemoveLazer:Clone()
s2.Parent = lazer
s2.Disabled = false
if hit then
print(hit.Parent.Name)
if hit.Parent:findFirstChild(Settings.HumanoidName) then
eHumanoid = hit.Parent[Settings.HumanoidName]
if Settings.TeamKill == true then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
elseif Settings.TeamKill == false then
ePlayer = Game.Players:GetPlayerFromCharacter(eHumanoid.Parent)
if ePlayer.TeamColor == Player.TeamColor then
print("Same Team!")
elseif ePlayer.TeamColor ~= Player.TeamColor then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
end
end
end
elseif hit == nil then
print("'hit' doesnt exist")
end
end
function Activated()
Fire()
end
Tool.Activated:connect(Activated) |
|
Bebee2Join Date: 2009-05-17 Post Count: 3985 |
ill give you the two lines of code that i you need.
hit,position = Game.Workspace:FindPartOnRay(ray,script.Parent.Parent)
Or
.
RayIgnore = {script.Parent.Parent}--tool,character
hit,position = Game.Workspace:FindPartOnRayWithIgnoreList(ray,RayIgnore)
|
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
umg i already tryed that... |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
tried* |
|
Bebee2Join Date: 2009-05-17 Post Count: 3985 |
"Settings.RayIgnore"
RayIgnore = {...
Not sure if custom environment or... |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
i have
Settings = {
}
then stuff. Please only respond if you are going to help. I would be getting a totally different error. |
|
L0cky2013Join Date: 2012-07-30 Post Count: 1446 |
RayIgnore = {script.Parent,script.Parent.Parent, Workspace.CurrentCamera} |
|
Bebee2Join Date: 2009-05-17 Post Count: 3985 |
Tried
hit,position = Game.Workspace:FindPartOnRayWithIgnoreList(ray,{script.Parent.Parent})
from a direct copy and paste and removed 3 lines because I don't have RemoveLazer within my tool
and it worked perfectly fine.
> Flamed before testing what I posted |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
im still hitting my character. |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
bump D: |
|
vlekje513Join Date: 2010-12-28 Post Count: 9057 |
Tool = script.Parent
Handle = Tool.Handle
Player = Game.Players.LocalPlayer
Settings = {
--GUN--
Damage = {10,30};
Range = 100;
MaxAmmo = 10;
ReloadTime = 2;
--OTHER--
HumanoidName = "Humanoid";
TeamKill = false;
RayIgnore = {script.Parent,script.Parent.Parent}
function Fire()
Character = Player.Character
Humanoid = Character.Humanoid
TargetPos = Humanoid.TargetPoint
Direction = (TargetPos - Character.Head.Position).unit
ray = Ray.new(Character.Head.Position,Direction*Settings.Range)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, RayIgnore)
distance = ((position - Tool.Handle.Position).magnitude)
lazer = Instance.new("Part",Game.Workspace)
lazer.Anchored = true
lazer.BrickColor = Player.TeamColor
lazer.Transparency = 0.5
lazer.BottomSurface = "Smooth"
lazer.TopSurface = "Smooth"
lazer.CanCollide = false
lazer.FormFactor = "Custom"
lazer.Size = Vector3.new(0.2,0.2,distance)
lazer.CFrame = CFrame.new(position,Tool.Handle.Position) * CFrame.new(0,0,-distance/2)
s2 = script.RemoveLazer:Clone()
s2.Parent = lazer
s2.Disabled = false
if hit then
print(hit.Parent.Name)
if hit.Parent:findFirstChild(Settings.HumanoidName) then
eHumanoid = hit.Parent[Settings.HumanoidName]
if Settings.TeamKill == true then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
elseif Settings.TeamKill == false then
ePlayer = Game.Players:GetPlayerFromCharacter(eHumanoid.Parent)
if ePlayer.TeamColor == Player.TeamColor then
print("Same Team!")
elseif ePlayer.TeamColor ~= Player.TeamColor then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
end
end
end
elseif hit == nil then
print("'hit' doesnt exist")
end
end
function Activated()
Fire()
end
Tool.Activated:connect(Activated) |
|
vlekje513Join Date: 2010-12-28 Post Count: 9057 |
Handle = Tool.Handle
Player = Game.Players.LocalPlayer
Settings = {
--GUN--
Damage = {10,30};
Range = 100;
MaxAmmo = 10;
ReloadTime = 2;
--OTHER--
HumanoidName = "Humanoid";
TeamKill = false;
RayIgnore = {script.Parent,script.Parent.Parent}
function Fire()
Character = Player.Character
Humanoid = Character.Humanoid
TargetPos = Humanoid.TargetPoint
Direction = (TargetPos - Character.Head.Position).unit
ray = Ray.new(Character.Head.Position,Direction*Settings.Range)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, Settings.RayIgnore)
distance = ((position - Tool.Handle.Position).magnitude)
lazer = Instance.new("Part",Game.Workspace)
lazer.Anchored = true
lazer.BrickColor = Player.TeamColor
lazer.Transparency = 0.5
lazer.BottomSurface = "Smooth"
lazer.TopSurface = "Smooth"
lazer.CanCollide = false
lazer.FormFactor = "Custom"
lazer.Size = Vector3.new(0.2,0.2,distance)
lazer.CFrame = CFrame.new(position,Tool.Handle.Position) * CFrame.new(0,0,-distance/2)
s2 = script.RemoveLazer:Clone()
s2.Parent = lazer
s2.Disabled = false
if hit then
print(hit.Parent.Name)
if hit.Parent:findFirstChild(Settings.HumanoidName) then
eHumanoid = hit.Parent[Settings.HumanoidName]
if Settings.TeamKill == true then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
elseif Settings.TeamKill == false then
ePlayer = Game.Players:GetPlayerFromCharacter(eHumanoid.Parent)
if ePlayer.TeamColor == Player.TeamColor then
print("Same Team!")
elseif ePlayer.TeamColor ~= Player.TeamColor then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
end
end
end
elseif hit == nil then
print("'hit' doesnt exist")
end
end
function Activated()
Fire()
end
Tool.Activated:connect(Activated) |
|
vlekje513Join Date: 2010-12-28 Post Count: 9057 |
Handle = Tool.Handle
Player = Game.Players.LocalPlayer
Settings = {
--GUN--
Damage = {10,30};
Range = 100;
MaxAmmo = 10;
ReloadTime = 2;
--OTHER--
HumanoidName = "Humanoid";
TeamKill = false;
RayIgnore = {script.Parent,script.Parent.Parent}
function Fire()
Character = Player.Character
Humanoid = Character.Humanoid
TargetPos = Humanoid.TargetPoint
Direction = (TargetPos - Character.Head.Position).unit
ray = Ray.new(Character.Head.Position,Direction*Settings.Range)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, Settings.RayIgnore)
distance = ((position - Tool.Handle.Position).magnitude)
lazer = Instance.new("Part",Game.Workspace)
lazer.Anchored = true
lazer.BrickColor = Player.TeamColor
lazer.Transparency = 0.5
lazer.BottomSurface = "Smooth"
lazer.TopSurface = "Smooth"
lazer.CanCollide = false
lazer.FormFactor = "Custom"
lazer.Size = Vector3.new(0.2,0.2,distance)
lazer.CFrame = CFrame.new(position,Tool.Handle.Position) * CFrame.new(0,0,-distance/2)
s2 = script.RemoveLazer:Clone()
s2.Parent = lazer
s2.Disabled = false
print(hit)
print(position)
if hit then
print(hit.Parent.Name)
if hit.Parent:findFirstChild(Settings.HumanoidName) then
eHumanoid = hit.Parent[Settings.HumanoidName]
if Settings.TeamKill == true then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
elseif Settings.TeamKill == false then
ePlayer = Game.Players:GetPlayerFromCharacter(eHumanoid.Parent)
if ePlayer.TeamColor == Player.TeamColor then
print("Same Team!")
elseif ePlayer.TeamColor ~= Player.TeamColor then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
end
end
end
elseif hit == nil then
print("'hit' doesnt exist")
end
end
function Activated()
Fire()
end
Tool.Activated:connect(Activated) |
|
vlekje513Join Date: 2010-12-28 Post Count: 9057 |
Handle = Tool.Handle
Player = Game.Players.LocalPlayer
Settings = {
--GUN--
Damage = {10,30};
Range = 100;
MaxAmmo = 10;
ReloadTime = 2;
--OTHER--
HumanoidName = "Humanoid";
TeamKill = false;
RayIgnore = {Player.Character}
function Fire()
Character = Player.Character
Humanoid = Character.Humanoid
TargetPos = Humanoid.TargetPoint
Direction = (TargetPos - Character.Head.Position).unit
ray = Ray.new(Character.Head.Position,Direction*Settings.Range)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, Settings.RayIgnore)
distance = ((position - Tool.Handle.Position).magnitude)
lazer = Instance.new("Part",Game.Workspace)
lazer.Anchored = true
lazer.BrickColor = Player.TeamColor
lazer.Transparency = 0.5
lazer.BottomSurface = "Smooth"
lazer.TopSurface = "Smooth"
lazer.CanCollide = false
lazer.FormFactor = "Custom"
lazer.Size = Vector3.new(0.2,0.2,distance)
lazer.CFrame = CFrame.new(position,Tool.Handle.Position) * CFrame.new(0,0,-distance/2)
s2 = script.RemoveLazer:Clone()
s2.Parent = lazer
s2.Disabled = false
print(hit)
print(position)
if hit then
print(hit.Parent.Name)
if hit.Parent:findFirstChild(Settings.HumanoidName) then
eHumanoid = hit.Parent[Settings.HumanoidName]
if Settings.TeamKill == true then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
elseif Settings.TeamKill == false then
ePlayer = Game.Players:GetPlayerFromCharacter(eHumanoid.Parent)
if ePlayer.TeamColor == Player.TeamColor then
print("Same Team!")
elseif ePlayer.TeamColor ~= Player.TeamColor then
eHumanoid.Health = eHumanoid.Health - math.random(Settings.Damage[1],Settings.Damage[2])
end
end
end
elseif hit == nil then
print("'hit' doesnt exist")
end
end
function Activated()
Fire()
end
Tool.Activated:connect(Activated) |
|