the title explains it self, im making a top down rpg game, just like guest quest, i need help with something tho.

thats my code for now, its a local script inside of starter character scripts:

local rayDirection = Vector3.new(0,1,0)

local char = game.Players.LocalPlayer.Character

local RAY_LENGTH = 30


function findAllPartsOnRay(ray)
	local targets = {}
	repeat
		local target = game.Workspace:FindPartOnRayWithIgnoreList(ray, targets)
		if target then
			table.insert(targets, target)
		end
	until not target
	return targets
end

game:GetService("RunService").Heartbeat:Connect(function()
	local ray = Ray.new(char.Head.Position,rayDirection * RAY_LENGTH)
	
	
	local parts = findAllPartsOnRay(ray)
	if parts then
		for index, value in ipairs(parts) do
			value.Transparency = 0.7
			wait()
			value.Transparency = 0
		end
	end
end)

i mean it works but it keeps blinking, so i want to make that the part becomes visible only when the ray its not hitting it

1 comment

0

if you're confused, i want to make that the part that gets hit, become invisible, but it keeps blinking, this feature will be useful when making caves on my top down rpg game