What do you want to achieve? Detecting if the ray has hit an object
What is the issue? Sometimes it picks up on the player’s object, when I want it to constantly pick up on the object
What solutions have you tried so far? Looking on the devforum where I found the solution to my original issue, but I cannot find a fix to this issue
The script is down below. (make sure to replace the “PUT YOUR PLAYERS NAME HERE” part with your roblox username
local beam = Instance.new("Beam")
local part = Instance.new("Part")
part.CanCollide = false
part.Transparency = 1
part.Parent = game.Workspace
part.Anchored = true
part.Size = Vector3.new(0,0,0)
local att = Instance.new("Attachment")
att.Parent = part
local part2 = Instance.new("Part")
part2.Parent = game.Workspace
part2.CanCollide = false
part2.Transparency = 1
part2.Anchored = true
part2.Size = Vector3.new(0,0,0)
local att2 = Instance.new("Attachment")
att2.Parent = part2
beam.Parent = script.Parent
beam.Attachment0 = att
beam.Attachment1 = att2
repeat wait() until game.Players:WaitForChild("PUT YOUR PLAYERS NAME HERE")
wait(1)
while true do
wait()
local ray = workspace:Raycast(script.Parent.Position, game.Players.dappa2000.Character.HumanoidRootPart.Position)
if ray ~= nil then
print(ray.Instance.Name)
end
part.Position = script.Parent.Position
part2.Position = game.Players.dappa2000.Character.HumanoidRootPart.Position
end
This hurts my eyes while reading, but if you meant that it collides with the player, then you should use raycastparams with exclude and put the character inside of the argument.
Oh sorry, I was trying to say that I need to see if it is colliding with the player, and if it isn’t to pick up on that. Sorry, sometimes I can yap on about nonsense
ok wait i see the problem:
raycast has 3 arguments:
start
direction
raycastparams (we dont need this)
the problem is that your direction is just the rootpart position, but i should be:
local direction = rootpart.position - start position if i am correct.