I made a graffiti tool, and you draw by holding on the left click.
As you see from the image, the first line is drew while moving mouse fast, second line is moving mouse normally and the third line is when moving mouse slowly.
I want it no matter the speed, for the gaps to be filled, and look like the last line.
Here’s my code:
Code
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
local runService = game:GetService("RunService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")
local brushRaycastModule = require(replicatedStorage.BrushRaycastModule)
local localPlayer = players.LocalPlayer
local character = localPlayer.CharacterAdded:Wait()
local mouse = localPlayer:GetMouse()
local personalPaintFolder = workspace.Paints.Players:WaitForChild(localPlayer.Name)
local clientPaintFolder = personalPaintFolder:WaitForChild("ClientPaint")
local serverPaintFolder = personalPaintFolder:WaitForChild("ServerPaint")
local paintQueueFolder = personalPaintFolder:WaitForChild("PaintQueue")
local handlers = script.Parent
local setPaintEvent = handlers.SetPaint
local sprayTool = handlers.Parent
local equipped = false
local brush = script.Brush
local brushFrame = brush.BrushGUI.BrushColor
brush.Parent = replicatedStorage
local brushProperties = sprayTool.Properties
local brushColor = brushProperties.BrushColor
local brushOpacity = brushProperties.BrushOpacity
local brushSize = brushProperties.BrushSize
local mouseDown = false
local function updatePaintOnServer()
local dataToSend = { }
for _, brushInQueue in pairs(paintQueueFolder:GetChildren()) do
table.insert(dataToSend,
{
["CFrame"] = brushInQueue:GetAttribute("CFrame"),
["Color"] = brushInQueue:GetAttribute("Color"),
["Opacity"] = brushInQueue:GetAttribute("Opacity"),
["Size"] = brushInQueue:GetAttribute("Size")
}
)
brushInQueue:Destroy()
end
setPaintEvent:FireServer(dataToSend)
end
local function previewBrush()
local ignoreList = { localPlayer.Character, brush, clientPaintFolder }
--]] Get characters and putting them in the ignore list [[--
for _, player in pairs(players:GetPlayers()) do
table.insert(ignoreList, player.Character)
end
local brushRay = brushRaycastModule.raycast(ignoreList)
if brushRay then
brush.Parent = personalPaintFolder
local normal = brushRay.Normal
brush.CFrame = CFrame.new(brushRay.Position, brushRay.Position + normal)
if mouseDown then
local c = brush:Clone()
c.Anchored = true
c.BrushGUI.AlwaysOnTop = false
c.BrushGUI.LightInfluence = 1
c.Parent = clientPaintFolder
local paintServerQueue = Instance.new("Configuration")
paintServerQueue.Name = "Paint"
paintServerQueue:SetAttribute("CFrame", c.CFrame)
paintServerQueue:SetAttribute("Color", c.BrushGUI.BrushColor.BackgroundColor3)
paintServerQueue:SetAttribute("Opacity", c.BrushGUI.BrushColor.BackgroundTransparency)
paintServerQueue:SetAttribute("Size", brush.Size.X)
paintServerQueue.Parent = paintQueueFolder
end
else
brush.Parent = replicatedStorage
end
end
runService.RenderStepped:Connect(function()
if equipped then
previewBrush()
end
end)
userInputService.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseDown = true
end
end)
userInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseDown = false
end
end)
--]] Check if tool is equipped [[--
sprayTool.Equipped:Connect(function()
equipped = true
brush.Parent = personalPaintFolder
end)
sprayTool.Unequipped:Connect(function()
equipped = false
brush.Parent = replicatedStorage
end)
--]] Server paint remover (still visible on other clients, only not visible on local client) [[--
serverPaintFolder.ChildAdded:Connect(function(child)
debris:AddItem(child, 0)
end)
while task.wait(1) do
updatePaintOnServer()
end