I’ve been repeatedly reading this for 5 minutes and I still haven’t gotten a grasp on how I’ll do this
-- 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(rayOrigin, rayDirection, 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 = v;
table.insert("FinishedTiles", DoneValue);
Raycast(Tile.Position, Vector3.new(0, 0, -0.3));
Raycast(Tile.Position, Vector3.new(0, 0, 0.3));
Raycast(Tile.Position, Vector3.new(-0.3, 0, 0));
Raycast(Tile.Position, Vector3.new(0.3, 0, 0));
end
end
for _, Value in pairs(FinishedTiles) do
Value:Destroy();
end
put Origin, and Direction(UHHHH CHARACTER LIMIT)
lol, which direction tho there are 4 directions that need to be shot
you have to right
local raycastResult = workspace:Raycast(Origin, Direction, raycastParams);
oh aight, are they just going to be nil?, like i’m going to have to activate it like this?
what are you doing? is there more part where you need to do raycast?
I’m already did the function right here
yeah but what am i going to put in the brackets?
why do you need to do more raycast? if you just want to learn then, the first parameter goes the Origin of the raycast, and the second one is the Direction of the raycast
It’s a local function, how am I going to activate it?
what will i put for the variables of Origin and Direction? will it just be a nil object?
wait nvm, i see it now it’s seperate, sorry. I am high i apologize for disturbing you i feel rlly stupid rn
Raycast(Vector3.new(0, 0, 0), Vector3.new(1, 1, 1));
Really sorry, you can rest easy now thank you! i’ll start testing it.
for some reason the ray casts extends itself to like this any ideas why?
the size of each pixel is 0.6x0.6 studs
you didn’t change the code at all? except the raycast part?
I changed the code so that it doesn’t delete the parts, other than that, nothing i could think of
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)
wait I thought you wanted to delete the BoolValue named Done?
I changed it to 0.1 because of the bug