Hi
I have made a spray can system but the spray parts don’t get the orientation of the object. So spraying it on the floor works but when I spray it on a wall it’s still horizontal
Client Script:
coroutine.resume(coroutine.create(function()
while true do
if isPainting then
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
local ignoreDescendants = {workspace.SprayPaint}
for i,v in pairs(game:GetService("Players"):GetChildren()) do
local char = v.Character or v.CharacterAdded:Wait()
if char then
table.insert(ignoreDescendants, char)
end
end
params.FilterDescendantsInstances = ignoreDescendants -- 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 result.Instance and result.Position then
script.Parent:WaitForChild("Paint"):FireServer(result.Position)
end
end
task.wait(0.02)
end
end))
Server script just fires an event to all clients.
The event is received in this local script:
local RS = game:GetService(“ReplicatedStorage”)
RS:WaitForChild(“SprayPaint”).OnClientEvent:Connect(function(pos)
local part = RS:WaitForChild("PaintPart"):Clone()
part.Parent = workspace.SprayPaint
part.Anchored = true
part.Position = pos
part.Size = Vector3.new(1, 0.008, 1)
part.Material = Enum.Material.SmoothPlastic
end)
Thanks