I changed the script to change the current_part to red.
as you can see, it’s making all the other parts the current_part I don’t know why.
would you like me to build a little thing so you can see what I’m trying to do?
I changed the script to change the current_part to red.
as you can see, it’s making all the other parts the current_part I don’t know why.
would you like me to build a little thing so you can see what I’m trying to do?
That’s strange cause your code doesnt seem to do that I only changed the current part whenever you mine so hmm
Ah you don’t need to I think ik whats going on now
Huh, well heres the entire thing updated:
local work_space = game:GetService("Workspace")
local player_service = game:GetService("Players")
local first_part = work_space:WaitForChild("mineablePart")
local mined_table = {}
local function on_part_click(current_part)
local part_cframe = current_part.CFrame
local part_size = current_part.Size
local parts_sides = {
part_cframe.LookVector * part_size.Z / 2 * 2,
part_cframe.LookVector * -part_size.Z / 2 * 2,
part_cframe.RightVector * part_size.X / 2 * 2,
part_cframe.RightVector * -part_size.X / 2 * 2,
part_cframe.UpVector * part_size.Y / 2 * 2,
part_cframe.UpVector * -part_size.Y / 2 * 2
}
for _, v in pairs(parts_sides) do
if not mined_table[v] then
local new_part = current_part:Clone()
new_part.Position = current_part.Position + v
new_part.Parent = work_space
if new_part:FindFirstChild("ClickDetector") then
new_part.ClickDetector.MouseClick:Connect(function()
on_part_click(new_part)
mined_table[v] = true
--new_part:Destroy()
new_part.Color = Color3.fromRGB(444)
end)
else
local click_detector = Instance.new("ClickDetector")
click_detector.Parent = new_part
click_detector.MouseClick:Connect(function()
on_part_click(new_part)
mined_table[v] = true
--new_part:Destroy()
new_part.Color = Color3.fromRGB(444)
end)
end
end
end
table.clear(parts_sides)
end
first_part.ClickDetector.MouseClick:Connect(function()
on_part_click(first_part)
first_part:Destroy()
mined_table[first_part.Position] = true
end)
I don’t think I really changed anything.
Maybe add a print after you check this
Then try that test that makes the three parts the current part again. Let’s see what it does
Here, I put v to be printed and this is what it outputted.
03:28:56.613 0, 0, 5 - Server - MiningSystem:26
03:28:56.613 5, 0, 0 - Server - MiningSystem:26
03:28:56.613 -5, -0, -0 - Server - MiningSystem:26
03:28:56.613 0, 5, 0 - Server - MiningSystem:26
03:28:56.613 -0, -5, -0 - Server - MiningSystem:26
03:28:57.157 -0, -0, -5 - Server - MiningSystem:26
03:28:57.158 0, 0, 5 - Server - MiningSystem:26
03:28:57.158 5, 0, 0 - Server - MiningSystem:26
03:28:57.158 -5, -0, -0 - Server - MiningSystem:26
03:28:57.158 0, 5, 0 - Server - MiningSystem:26
03:28:57.158 -0, -5, -0 - Server - MiningSystem:26
03:28:58.008 -0, -0, -5 - Server - MiningSystem:26
03:28:58.009 5, 0, 0 - Server - MiningSystem:26
03:28:58.009 -5, -0, -0 - Server - MiningSystem:26
03:28:58.009 0, 5, 0 - Server - MiningSystem:26
03:28:58.009 -0, -5, -0 - Server - MiningSystem:26
also, thanks for staying around for this long, I know this is annoying to try to get to work.
Dang okay actually maybe let’s try something else. And give the parts an individual unique name like:
Part1
Part2
Part3
Making a system like that would just be like having an incremental value y’know
local amount = 1
local Newpart = …
Newpart.Name = "Part"..amount
amount += 1
-- named "Part1"
local Anotherpart= …
Anotherpart.Name = "Part"..amount
amount += 1
-- named "Part2"
Under this line:
AND this line:
Print out the name of the current part
I’m doing this to see when you click those red parts, like whether or not it registers the click for the other two parts
Give me a minute, I’m going to try to redo this script.
hopefully I can make it better, and maybe get it to work.
Alright btw someone just pmed another solution other than look vectors so maybe you can the that too if your rework doesn’t work
I found out a way to do this, it only took like an hour? lol.
thank to @Doomcolp so much for his awesome vector drawing and helping me the entire way, without him this wouldn't have been done.
fixed script for people who run into this problem.
local work_space = game:GetService("Workspace")
local first_part = work_space:WaitForChild("mineablePart")
local mined_table = {}
local function on_part_click(current_part)
local part_cframe = current_part.CFrame
local part_size = current_part.Size
local part_position = current_part.Position
local parts_sides = {
part_cframe.LookVector * part_size.Z / 2 * 2,
part_cframe.LookVector * -part_size.Z / 2 * 2,
part_cframe.RightVector * part_size.X / 2 * 2,
part_cframe.RightVector * -part_size.X / 2 * 2,
part_cframe.UpVector * part_size.Y / 2 * 2,
part_cframe.UpVector * -part_size.Y / 2 * 2
}
for _, v in pairs(parts_sides) do
local current_position = (part_position + v)
if not mined_table[current_position] then
mined_table[current_position] = true
local new_part = first_part:Clone()
new_part.Parent = work_space
new_part.Position = current_part.Position + v
if new_part:FindFirstChild("ClickDetector") then
new_part.ClickDetector.MouseClick:Connect(function()
new_part:Destroy()
on_part_click(new_part)
end)
else
local click_detector = Instance.new("ClickDetector")
click_detector.Parent = new_part
click_detector.MouseClick:Connect(function()
new_part:Destroy()
on_part_click(new_part)
end)
end
end
end
end
first_part.ClickDetector.MouseClick:Connect(function()
mined_table[first_part.Position] = true
on_part_click(first_part)
first_part:Destroy()
end)
Thanks lol but I was kinda confused most of the time (that’s why it took so long to reply)
But you actually did most of the work, I didn’t do as much so congratulate yourself!!
Well you’re getting there already!
Yeah, but you helped me a lot, I took my time with remaking it, but I couldn’t have done it without you, and because of you I understand lookvector etc a lot better.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.