Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to get a Part's surface(Front, Bottom, etc)?

Hi! I'm making a script where you can spray a logo on a part but the thing is I don't know how to make it so that it sprays the logo on the part's surface that you're facing. Can you help me?

This is what I have so far:

local UIS = game:GetService("UserInputService")

local mouse = game.Players.LocalPlayer:GetMouse()

local player = game.Players.LocalPlayer

local character = player.Character

local humanoid = character:WaitForChild("Humanoid")

local SprayPoints = game.Workspace:GetDescendants()

local Equipped = false

local canSpray = true

local spraying = false

local maxDistance = 10

local SpraySound = Instance.new("Sound", script.Parent)

SpraySound.Name = "SpraySound"

SpraySound.SoundId = "https://www.roblox.com/asset/?id=843338638"

UIS.InputBegan:Connect(function(input, gameProcessed)
	if gameProcessed then
		return
	end
	if input.KeyCode == Enum.KeyCode.E and canSpray then
		if Equipped == false then
			Equipped = true
			print("Equipped is ", Equipped)
		else
			Equipped = false
			print("Equipped is ", Equipped)
		end
	end
	
	mouse.Button1Down:Connect(function()
		if Equipped then
			print("Pressed")
			local target = mouse.Target
			print(target.Name)
			if (character.UpperTorso.Position - mouse.Hit.p).magnitude <= maxDistance and spraying == false then
				canSpray = true
			else
				canSpray = false
			end
			if target and spraying == false and canSpray then
				canSpray = false
				spraying = true
				SpraySound:Play()
				local SprayTexture = Instance.new("Decal")
				SprayTexture.Name = "SprayTexture"
				SprayTexture.Texture = "http://www.roblox.com/asset/?id=4552976698"
				SprayTexture.Parent = target
				spraying = false
				canSpray = true
			end
		else
			print("Can't press")
		end
	end)
end)

1 answer

You can get parts surfaces with part.TopSurface, part.BottomSurface part,FrontSurface

But spray paints make a new part and put a decal on it and plaster it to a wall

This discussion is preserved as it was. New answers, comments, and votes are closed.