Hey all,
Recently I’ve been making a build tool. However, I cannot find the way to fix requiring to select a color each and every time you want to place a block.
Video:
Hey all,
Recently I’ve been making a build tool. However, I cannot find the way to fix requiring to select a color each and every time you want to place a block.
Video:
Can we see your script please. So once they select a color you want them to be able to multi place blocks?
The script is in the post. And yes, insead of selecting the color every time, you could just select one and place without pressing it every block.
You could just do this, and to get out of multi place just press the “X” key. Replace this code
With this
local Con
UserInputService.InputBegan:Connect(function(input)
if Input.KeyCode == Enum.KeyCode.X then
Con:Disconnect()
end
end)
for i,v in pairs(frame:GetChildren()) do
if v:IsA("ImageButton") then
v.Activated:Connect(function()
print(v.BackgroundColor3)
Color = v.BackgroundColor3
Con = mouse.Button1Down:Connect(function()
Block()
end)
end)
end
end
You are making the click event inside the function where they select a color and disconnecting it right after. Delete that event and move it outside like this:
mouse.Button1Down:Connect(function()
if Color then
Block()
end
end)
These do fix the issue, but another issue happens. Whenever switching colors, it will duplicate the part.
Video:
That shouldn’t happen unless you haven’t deleted this
I have deleted it, and I can confirm it is indeed happening.
Maybe try this?
local Con
UserInputService.InputBegan:Connect(function(input)
if Input.KeyCode == Enum.KeyCode.X then
Con:Disconnect()
end
end)
for i,v in pairs(frame:GetChildren()) do
if v:IsA("ImageButton") then
v.Activated:Connect(function()
if Con then Con:Disconnect() end
Color = v.BackgroundColor3
Con = mouse.Button1Down:Connect(function()
Block()
end)
end)
end
end
It fixed the new issue, but now goes straight back to issue #1.
Also, I had to move
Con = mouse.Button1Down:Connect(function()
Because Con:Disconnect() was not able to get it.
This is all I can think of:
local placing = false
UserInputService.InputBegan:Connect(function(input)
if Input.KeyCode == Enum.KeyCode.X then
placing = false
end
end)
for i,v in pairs(frame:GetChildren()) do
if v:IsA("ImageButton") then
v.Activated:Connect(function()
Color = v.BackgroundColor3
placing = true
end)
end
end
mouse.Button1Down:Connect(function()
if placing then Block() end
end)
Well, it worked! Thank you for all the help!
Make sure to mark his reply as the solution.
I already did set it as solution.
I see. Didn’t show up on my screen, but my mistake regardless I guess.