I’m new to this side of Roblox scripting as I only know the basics, like part manipulation, but I don’t know much past that.
I want this script to be serverside for a canvas game:
local Tool = script.Parent
local gui = Tool:WaitForChild('Paintbucket')
local current = Tool.Value
local container = gui.Drag.Main.Scroll
local p = game.Players.LocalPlayer
local pgui = p.PlayerGui
local mouse = p:GetMouse()
local heartbeat = game:GetService('RunService').Heartbeat
local function hwait()
return heartbeat:Wait()
end
local selectionBox = Instance.new('SelectionBox', p.Character)
local selectionLasso = Instance.new('SelectionPartLasso', p.Character)
selectionLasso.Humanoid = p.Character.Humanoid
for _,button in next, container:GetChildren() do
button.MouseButton1Click:Connect(function()
if button.Name ~= current.Value.Name then
for i = 2,0,-1 do
container:FindFirstChild(current.Value.Name).BorderSizePixel = i
hwait()
end
current.Value = BrickColor.new(button.Name)
for i = 0,2 do
button.BorderSizePixel = i
hwait()
end
container.Parent.Selected.Text = current.Value.Name
end
end)
end
function setSelectionBox(part)
unsetSelectionBox()
selectionBox.Adornee = part
selectionLasso.Part = part
end
function unsetSelectionBox()
selectionBox.Adornee = nil
selectionLasso.Part = nil
end
function canSelectObject(part)
return part and not (part.Locked) and (part.Position - p.Character.Head.Position).Magnitude < 60
end
function setColor(part)
if canSelectObject(part) then
part.BrickColor = current.Value
Tool.Handle.PaintSound:Play()
Tool.Handle.PaintSound.PlaybackSpeed = .9 + (math.random() * .1)
end
end
game:GetService('RunService').RenderStepped:Connect(function()
if gui.Enabled then
local part = mouse.Target
if canSelectObject(part) then
mouse.Icon ="rbxasset://textures\\FillCursor.png"
setSelectionBox(part)
else
mouse.Icon = ''
unsetSelectionBox()
end
end
end)
mouse.Button1Down:Connect(function()
setColor(mouse.Target)
print(tostring(p) .. " painted " .. mouse.Target.Name .. " with the colour " .. tostring(current.Value) .. "!")
end)
gui.Parent = pgui
Tool.Equipped:Connect(function()
gui.Drag.Position = UDim2.new(0,0,0.5,-230)
gui.Enabled = true
end)
Tool.Unequipped:Connect(function()
gui.Enabled = false
end)
I don’t know what to change at all. Where do I start ?