You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
make that the paints that the players do show for all players not only local -
What is the issue? Include screenshots / videos if possible!
idk how to do it, maybe with a remote event? -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
tried with remotes event
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local user = game.Players.LocalPlayer
local uname = user.Name
local guis = user.PlayerGui
local pack = user.Backpack
local keyDowns = {}
local freeKeys = {}
local shortcuts = {}
_G.mine = _G.mine or {}
local name = 'Drawing Tool'
local url = 'http://www.roblox.com/asset/?id=%d'
local iconNormal = url:format(96578285)
local iconOnDown = url:format(96584484)
local ver = 0
local drawPixel = 0.10
_G.drawLimit = _G.drawLimit or 1000
_G.drawColor = _G.drawColor or Color3.new()
local destroy = game.Remove
local find = game.FindFirstChild
local new = Instance.new
-- Styling properties
local backgroundColor = Color3.fromRGB(30, 30, 30)
local buttonColor = Color3.fromRGB(0, 123, 255)
local buttonTextColor = Color3.fromRGB(255, 255, 255)
local textColor = Color3.fromRGB(255, 255, 255)
local function with(c)
return function(p)
local o = typeof(c) == 'string' and new(c) or c
local x = p.Parent
p.Parent = nil
for i, v in pairs(p) do
o[i] = v
end
if x then
o.Parent = x
end
return o
end
end
local function createGuiElement(className, properties)
local element = new(className)
for property, value in pairs(properties) do
element[property] = value
end
return element
end
local function createTextLabel(text, position, size)
return createGuiElement('TextLabel', {
Text = text,
Position = position,
Size = size,
BackgroundColor3 = backgroundColor,
TextColor3 = textColor,
TextScaled = true,
TextWrapped = true,
Font = Enum.Font.SourceSansBold,
})
end
local function createTextButton(text, position, size, onClick)
local button = createGuiElement('TextButton', {
Text = text,
Position = position,
Size = size,
BackgroundColor3 = buttonColor,
TextColor3 = buttonTextColor,
TextScaled = true,
Font = Enum.Font.SourceSansBold,
})
button.MouseButton1Click:Connect(onClick)
return button
end
local function getPlace()
if not find(workspace, 'draw') then
new('Model', workspace).Name = 'draw'
end
if not find(workspace.draw, uname) then
new('Model', workspace.draw).Name = uname
end
return workspace.draw[uname]
end
local function drawLine(start, target)
local gui = with('BlockMesh') {
Parent = with('Part') {
CFrame = CFrame.new(start, target) * CFrame.new(0, 0, -(start - target).Magnitude / 2),
Size = Vector3.new(drawPixel, drawPixel, (start - target).Magnitude + 0.325 * drawPixel),
Parent = getPlace(),
Color = _G.drawColor,
BottomSurface = Enum.SurfaceType.Smooth,
Anchored = true,
TopSurface = Enum.SurfaceType.Smooth,
FormFactor = Enum.FormFactor.Symmetric,
Name = name
}
}.Parent
table.insert(_G.mine, gui)
return gui
end
local function onDown()
if drawing then
return nil
end
if selectGui.Adornee then
destroy(selectGui.Adornee)
end
drawing = true
mouse.Icon = iconOnDown
ver = ver + 1
local cVer, start, target = ver, mouse.Hit.Position
local group = {}
repeat
wait(0.02)
if mouse.Target and mouse.Target.Name ~= name and mouse.Hit.Position ~= start then
target = mouse.Hit.Position
table.insert(group, drawLine(start, target))
start = target
end
until ver ~= cVer
drawing = false
local groupM = new('Model', getPlace())
for i, v in pairs(group) do
if v:IsDescendantOf(workspace) then
v.Parent = groupM
end
end
if next(groupM:GetChildren()) == nil then
destroy(groupM)
end
end
local function onUp()
mouse.Icon = iconNormal
ver = ver + 1
end
local function onKeyDown(k)
if freeKeys[k] == false then
return false
end
freeKeys[k] = false
wait(0.01)
if keyDowns[k] then
keyDowns[k]()
elseif shortcuts[k] then
shortcuts[k]()
end
end
local function onKeyUp(k)
freeKeys[k] = true
end
local function onMove()
end
local function onSelect(lmouse)
frame.Visible = true
mouse = lmouse
mouse.Icon = iconNormal
mouse.Button1Down:Connect(onDown)
mouse.KeyDown:Connect(onKeyDown)
mouse.Button1Up:Connect(onUp)
mouse.KeyUp:Connect(onKeyUp)
mouse.Move:Connect(onMove)
end
local function onDeselect()
ver = ver + 1
frame.Visible = false
selectGui.Adornee = nil
mouse.Icon = iconNormal
for i, v in pairs(freeKeys) do
freeKeys[i] = true
end
end
local function addButton(title, shortcut, fun)
local textButton = createTextButton(title, UDim2.new(0, 0, 0, 20 * #frame:GetChildren()), UDim2.new(1, 0, 0, 20), fun)
textButton.Parent = frame
shortcuts[shortcut] = fun
local c = #frame:GetChildren()
for i, v in pairs(frame:GetChildren()) do
v.Position = UDim2.new(0, 0, 0, 20 * (i - 1))
v.Size = UDim2.new(1, 0, 0, 20)
end
frame.Position = UDim2.new(1, -152, .5, -c * 10)
frame.Size = UDim2.new(0, 150, 0, c * 20)
end
for i, v in pairs({ guis, pack }) do
pcall(function()
repeat until destroy(v:FindFirstChild(name))
end)
end
local pencil = game.ReplicatedStorage.Pencil:Clone()
pencil.RequiresHandle = true
pencil.Name = name
pencil.TextureId = "http://www.roblox.com/asset/?id=12634080850"
pencil.ToolTip = "Pencil"
pencil.Parent = pack
pencil.Equipped:Connect(onSelect)
pencil.Unequipped:Connect(onDeselect)
local screen = createGuiElement('ScreenGui', {
Parent = guis,
Name = name
})
frame = createGuiElement('Frame', {
Parent = screen,
Visible = false,
BackgroundColor3 = backgroundColor,
})
clframe = createGuiElement('Frame', {
Position = UDim2.new(.5, -50, .5, -50),
Size = UDim2.new(0, 100, 0, 100),
Visible = false,
Parent = screen,
BackgroundColor3 = backgroundColor,
})
selectGui = with('SelectionBox') {
Parent = screen
}
local c = 0
for y = 0, 7 do
for x = 0, 7 do
local color = BrickColor.palette(c).Color
local imageButton = with('ImageButton') {
Position = UDim2.new(.125 * x, 0, .125 * y),
Size = UDim2.new(.125, 0, .125),
BackgroundColor3 = color,
Parent = clframe
}
imageButton.MouseButton1Up:Connect(function()
clframe.Visible = false
_G.drawColor = color
end)
c = c + 1
end
end
addButton('Color', 'c', function()
clframe.Visible = true
end)
addButton('Remove your draws', 'r', function()
repeat
destroy(_G.mine[1])
table.remove(_G.mine, 1)
wait(0.01)
until not next(_G.mine)
end)
addButton('Remove global draws', 'k', function()
destroy(workspace.draw)
while _G.mine[1] do
destroy(_G.mine[1])
table.remove(_G.mine, 1)
end
end)
addButton('Remove selected', 'x', function()
repeat
if find(workspace, 'draw') then
local dt = mouse.Target
if dt and dt:IsDescendantOf(workspace.draw) then
selectGui.Adornee = dt.Parent
else
selectGui.Adornee = nil
end
else
selectGui.Adornee = nil
end
wait(0.01)
until freeKeys.x
selectGui.Adornee = nil
end)
repeat
wait(0.01)
if next(_G.mine) and _G.mine[_G.drawLimit] then
destroy(_G.mine[1])
table.remove(_G.mine, 1)
end
until script.Parent == nil or pencil.Parent == nil
script.Disabled = true
destroy(screen)
making it a normal script breaksthe code