Hello!
I have two annoying problems right now… I really don’t know how to solve this…
Note: The code is below and applies to both issues.
First Problem
I have a kind of “cube whiteboard”, where each Frame is a face of a cube that you can paint on. The thing is that I have a problem, and that is that there are certain parts of those faces (frames) that cannot be painted. (You can see the black edges and certain inconsistencies because you cannot paint on those parts for some reason that I don’t know).
Original
Full Painted
Second Problem
I also have a problem with the size of the Dot while painting (especially when painting near the edges), since by maintaining its size, a part is painted outside the frame.
Dot Size Problem
Code
Client
local lPlr = game.Players.LocalPlayer
local mouse = lPlr:GetMouse()
local uis = game:GetService("UserInputService")
local Flash_DrawScript = game:GetService("ReplicatedStorage"):WaitForChild("Flash_DrawScript")
local isMouseButtonDown = false
local function InputBegan(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
isMouseButtonDown = true
end
end
function InputEnded(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
isMouseButtonDown = false
end
end
for _, frame in ipairs(lPlr.PlayerGui.DrawGui:GetChildren()) do
if not frame:IsA("Frame") or frame.Name == "Options" then return end
local function Paint(X, Y)
if isMouseButtonDown == false then return end
local gui_X = frame.AbsolutePosition.X
local gui_Y = frame.AbsolutePosition.Y
local guiPosition = frame.AbsolutePosition
local guiSize = frame.AbsoluteSize
local relativePos = UDim2.new((X -guiPosition.X) / guiSize.X, 0, (Y -guiPosition.Y - 36) / guiSize.Y, 0)
local DotSize = lPlr.PlayerGui.DrawGui.Options.DotSize
if DotSize.Text == "" or DotSize.Text == "0" then end
if not tonumber(DotSize.Text) then return end
if tonumber(DotSize.Text) and tonumber(DotSize.Text) <= 0 then return end
Flash_DrawScript:FireServer(frame, relativePos, tonumber(DotSize.Text))
end
uis.InputBegan:Connect(InputBegan)
uis.InputEnded:Connect(InputEnded)
frame.MouseMoved:Connect(Paint)
end
Server
local Flash_DrawScript = game:GetService("ReplicatedStorage"):WaitForChild("Flash_DrawScript")
Flash_DrawScript.OnServerEvent:Connect(function(plr, frame, relativePos, dotSize)
print("Relative position: " .. relativePos.X.Scale .. ", " .. relativePos.Y.Scale)
local dot = Instance.new("ImageLabel")
dot.Parent = frame
dot.Position = UDim2.new(relativePos.X.Scale, 0, relativePos.Y.Scale, 0)
dot.Name = "Dot"
dot.ImageColor3 = Color3.fromRGB(0, 0, 0)
dot.BackgroundTransparency = 1
dot.Size = UDim2.new(0, dotSize, 0, dotSize)
dot.Image = "http://www.roblox.com/asset/?id=279918838"
end)