How do I detect parts better

oh yeah that value doesn’t matter anymore

Replace the code with this

-- RaycastParams can be reused and making it each time you use raycast, will cuase lag
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;

local function Raycast(Player, Origin, Direction)
	raycastParams.FilterDescendantsInstances = {Player.Character};
	local raycastResult = game.Workspace:Raycast(Origin, Direction, raycastParams);

	if raycastResult then
		local hitPart = raycastResult.Instance;
		-- Check if the part resides in a folder, that it's fully visible, and not locked
		if hitPart:GetAttribute("Owner") == Player.PlayerValues.Attacking.Value then
			Player.PlayerValues.Pixels.Value += 1;
			hitPart.Color = Player.PlayerValues.ColorValue.Value;
			hitPart:SetAttribute("Owner", Player.Name);
		end
	end
end

game.ReplicatedStorage:WaitForChild(script.Name).OnServerEvent:Connect(function(plr)
	for _, Tile in pairs(workspace.Europe:GetChildren()) do
		if Tile:IsA("BasePart") and Tile:GetAttribute("Owner") == plr.Name and Tile:FindFirstChild("Done") == nil then
			Raycast(plr, Tile.Position, Vector3.new(0, 0, -2));
			Raycast(plr, Tile.Position, Vector3.new(0, 0, 2));
			Raycast(plr, Tile.Position, Vector3.new(-2, 0, 0));
			Raycast(plr, Tile.Position, Vector3.new(2, 0, 0));
		end
	end
end)

this still happens

could you send a screen shot of your whole script? from start to end


do you have discord? feel like it would be more efficient

wright

print(Origin, Direction, hitPart);

right after

if raycastResult then
		local hitPart = raycastResult.Instance;

and send me the screenshot of the output

image
here

If you’re willing to go this far to help me I could add you to a team create, if you’re willing to do it ofc

I have no idea what’s wrong, but I’m sure the code in’t broken, so my guess is that theres somthing wrong with the part where you’re checking if it can change the owner of the tile

In an abstract sense:

  1. Make the initial part and put it in a table of “exposed” parts (that you want to do a raycast on
  2. Send a raycast only from the “exposed parts”
  3. Put all of the raycast results into a new table, and overwrite the old table once you’re finished
  4. repeat 2-4

The same bug will probably happen because it’s using raycast, i’ll just give up on the project and think of something new, would love to work with someone but pretty sure you have to pay them :pensive:

the original was working, was it not? I thought the primary issue was lag

There’s this bug with the raycast system which extends it’s range farther than it’s supposed to, here’s a screen shot:
image
I have no ideas how to fix it, the other guy said there are some problems with checking the owner of the tile, but magnitude works perfectly idk tho

And what is the specific code that sends out these raycasts? It’s hard to sift through this entire post history.

game.ReplicatedStorage:WaitForChild(script.Name).OnServerEvent:Connect(function(plr)
	-- RaycastParams can be reused and making it each time you use raycast, will cuase lag
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = {plr.Character};
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist;

	local FinishedTiles = {};

	local function Raycast(Origin, Direction)
		local raycastResult = workspace:Raycast(Origin, Direction, raycastParams);

		if raycastResult then
			local hitPart = raycastResult.Instance;
			-- Check if the part resides in a folder, that it's fully visible, and not locked
			if hitPart:GetAttribute("Owner") == plr.PlayerValues.Attacking.Value then
				plr.PlayerValues.Pixels.Value += 1;
				hitPart.Color = plr.PlayerValues.ColorValue.Value;
				hitPart:SetAttribute("Owner",plr.Name);
			end
		end
	end

	for _, Tile in pairs(workspace.Europe:GetChildren()) do
		if Tile:IsA("BasePart") and Tile:GetAttribute("Owner") == plr.Name and Tile:FindFirstChild("Done") == nil then
			local DoneValue = Instance.new("BoolValue");
			DoneValue .Name = "Done";
			DoneValue .Parent = Tile;
			table.insert(FinishedTiles,Tile);

			Raycast(Tile.Position, Vector3.new(0, 0, -0.1));
			Raycast(Tile.Position, Vector3.new(0, 0, 0.1));
			Raycast(Tile.Position, Vector3.new(-0.1, 0, 0));
			Raycast(Tile.Position, Vector3.new(0.1, 0, 0));
		end
	end
	
	for i = 1,#FinishedTiles do
		table.remove(FinishedTiles,i)
	end
	
end)

I mean, for one, your Vectors should be a unit vector (magnitude of 1), since it’s a direction, not a second position. No clue what’s wrong at a glance though.

like vector3.Unit? also does this mean there’s no solution?

I’ll just drop the project seems like a dead end