I’m making a spray paint tool but I have a problem when I move the cusor fast gaps are left
This is the local spript in the tool(this is only a section of the script)
local function calculateSprayInfo()
local userInputService = game:GetService("UserInputService")
local mouseVP = userInputService:GetMouseLocation()
local mouseRay = workspace.CurrentCamera:ViewportPointToRay(mouseVP.x, mouseVP.y)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {workspace.SprayPaint, Player.Character, workspace.Monster, workspace.Waypoints, workspace.SpawnLocation} -- Put the new spray paint parts in that model so it can ignore them
local result = workspace:Raycast(mouseRay.Origin, mouseRay.Unit.Direction * 300, params)
-- Wall Painting here
print(result)
if result ~= nil then
sprayEvent:FireServer(result.Position, result.Normal)
generatedSound = spray:Clone()
generatedSound.PlayOnRemove = false
generatedSound.Parent = script
generatedSound:Play()
end
end
local function calculateSprayInfo()
local userInputService = game:GetService("UserInputService")
local mouseVP = userInputService:GetMouseLocation()
local mouseRay = workspace.CurrentCamera:ViewportPointToRay(mouseVP.x, mouseVP.y)
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = {workspace.SprayPaint, Player.Character, workspace.Monster, workspace.Waypoints, workspace.SpawnLocation} -- Put the new spray paint parts in that model so it can ignore them
local result = workspace:Raycast(mouseRay.Origin, mouseRay.Unit.Direction * 300, params)
if frame1 == nil then
frame1 = result.Position
end
frame2 = result.Position
local cylinder = game:GetService("ReplicatedStorage").Cylinder:Clone()
cylinder.Parent = workspace.SprayPaint
cylinder.CanCollide = false
cylinder.Anchored = true
local midpointFormula = (frame2.X - frame1.X)^2 + (frame2.Y - frame1.Y)^2
print(midpointFormula)
cylinder.Color = Color3.new(1, 0.952941, 0.278431)
-- Wall Painting here
print(result)
if result ~= nil then
sprayEvent:FireServer(result.Position, result.Normal)
generatedSound = spray:Clone()
generatedSound.PlayOnRemove = false
generatedSound.Parent = script
generatedSound:Play()
end
frame1 = result.Position
end