hi, i am trying to fix a system that detects if there is a part (technically, a car) over a certain pad. i’ve tested this on my baseplate and it works fine when I move the part a bit down and the car is over the part, however, when I test it in. the real game using almost the same method it doesnt work.
This is the code
local function CheckSpawnObstruction(SpawnPad)
local RAY_LENGTH = 5
local originPos = (SpawnPad.CFrame).p
local endPos = (SpawnPad.CFrame * CFrame.new(5, 0, 0)).p
local ray = Ray.new(SpawnPad.Position, endPos - originPos)
local hit, hitPosition = workspace:FindPartOnRay(ray, {workspace.SpawnerProps})
--local raycastResult = workspace:Raycast(SpawnPad.Position, endPos - originPos)
if not hit then
return true
end
end
I modified the code to
local function CheckSpawnObstruction(SpawnPad)
local RAY_LENGTH = 5
local originPos = (SpawnPad.CFrame).p
local endPos = (SpawnPad.CFrame * CFrame.new(0,5, 0)).p
local ray = Ray.new(SpawnPad.Position, endPos - originPos)
local hit, hitPosition = workspace:FindPartOnRay(ray)
--local raycastResult = workspace:Raycast(SpawnPad.Position, endPos - originPos)
if not hit then
return true
end
end
on my baseplate and it worked when the car model was in the part.
Any suggestions?
Thanks!
(sample pic of what happens)