I casted a ray like: local ray = workspace:Raycast(part.Position, part.CFrame.UpVector * -100)
But it isn’t returning anything, for example if i say: If ray then
Print(“hi”)
It doesn’t print hi?
I casted a ray like: local ray = workspace:Raycast(part.Position, part.CFrame.UpVector * -100)
But it isn’t returning anything, for example if i say: If ray then
Print(“hi”)
It doesn’t print hi?
Are you raycasting on the client? If so please send more information like screenshots so I can get to understand the script and find the issue easier.
I’m not… Is that a problem? [char limit]
it is, raycasting can only be done on local scripts or else it wont work.
I would recommend reading more about raycasting on here:
if a raycast doesn’t hit anything it will return nil.
I’m fairly sure raycasting can still be done on the server
U didn’t check the raycast result rapidly. U only check it once!!
The issue might be that the object is upside down. Flip the object 180 degrees and see if it still works
oop, my bad I actually didnt know that at all. Issue now could be where the ray is being casted at and if it even finds an object at the direction is currently looking.
local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
RunService.Heartbeat:connect(function()
if UIS:IsKeyDown(Enum.KeyCode.Q) then
local __Params = RaycastParams.new() — Optional
local __Result = workspace:Raycast(Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame, Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 50, __Params)
end
end)
I coded all this from memory & on my phone, hope it works! I forgot if both the origin & direction were suppose to be CFrame or Vector3.
It was simply because I had it on the wrong line
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.