Anyone know why my decal isn't appearing?

My goal for this script is whenever a player or a humanoid object gets hit with a pizza, a decal on their avatar should pop up on their torso. However, it is not appearing in this case. There is no errors to help explain why it is not working.


local Tool = script.Parent
local enabled = true
local THROW_FORCE = 60
local MIN_THROW_DELAY = 1

local DECAL_ID = "rbxassetid://9117409728"
local IMPACT_SOUND_ID = "rbxassetid://8595980577"

local canThrow = true

local MouseUpdate = Instance.new("RemoteEvent")
MouseUpdate.Name = "MouseUpdate"
MouseUpdate.Parent = Tool

local currentMousePosition = Vector3.new(0,0,0) --Default position

MouseUpdate.OnServerEvent:Connect(function(player, mousePos)
	currentMousePosition = mousePos
end)

local function onActivated()
	if not enabled or not canThrow then
		return
	end

	enabled = false
	canThrow = false

	local character = Tool.Parent
	local humanoid = character:FindFirstChild("Humanoid")
	if not humanoid then return end

	local torso = character:FindFirstChild("Torso") or character:FindFirstChild("HumanoidRootPart")
	if not torso then return end

	local handle = Tool.Handle:Clone()
	handle.Anchored = false
	handle.CanCollide = true
	handle.Parent = workspace
	handle.CFrame = Tool.Handle.CFrame

	-- Apply throwing force using the *latest* mouse position
	local throwDirection = (currentMousePosition - handle.Position).Unit
	handle:ApplyImpulse(throwDirection * THROW_FORCE * handle:GetMass())
	handle:SetNetworkOwner(nil)

	Tool.Enabled = false

	if Tool.Handle:FindFirstChild("BiteSound") then
		Tool.Handle.BiteSound:Play()
	end

	local function applyImpactEffects(hit)
		if hit and hit.Parent and hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= character then

			local decal = Instance.new("Decal")
			decal.Texture = DECAL_ID
			decal.Face = Enum.NormalId.Front
			decal.Parent = hit
			game.Debris:AddItem(decal, 5)

			local emitter = Instance.new("ParticleEmitter")
			emitter.Parent = hit
			emitter.Rate = 10
			emitter.Lifetime = NumberRange.new(0.5, 1)
			game.Debris:AddItem(emitter, 1)

			local sound = Instance.new("Sound")
			sound.SoundId = IMPACT_SOUND_ID
			sound.Parent = hit
			sound.Volume = 0.5
			sound:Play()

			local sound2 = Instance.new("Sound")
			sound2.SoundId = IMPACT_SOUND_ID
			sound2.Parent = hit.Parent.HumanoidRootPart
			sound2.Volume = 0.5
			sound2:Play()
		end
	end

	local connection = handle.Touched:Connect(applyImpactEffects)

	game.Debris:AddItem(handle, 3)

	wait(MIN_THROW_DELAY)
	if connection then connection:Disconnect() end
	Tool.Enabled = true
	enabled = true
	canThrow = true

end

local function onEquipped()
	if Tool.Handle:FindFirstChild("EquipSound") then
		Tool.Handle.EquipSound:Play()
	end
end

Tool.Activated:Connect(onActivated)
Tool.Equipped:Connect(onEquipped)

Video:

6 Likes

On this part of the script, shouldn’t decal.Parent instead of being “= hit” being equals the torso of what was hit?

4 Likes

No, I think either way would still lead the decal not popping up

2 Likes

Maybe ID is malfunctioning. I tried the ID you said you using (rbxassetid://9117409728) and didn’t work for me. Try to put something with this ID without the script to see if it appears as an image.

2 Likes

I don’t see anything either. I tried a different mesh ID in the script and still resulted into the same situation

2 Likes

You could first check if there’s a decal set by default. When you launch it, check the browser to see if any other decals are created in real time.

You can also check if “Tool.Handle” has the correct orientation when you launch it, since you use “handle.Position” to ensure it’s correct and the script works.

1 Like

u can use print("Impact on:", hit.Name)

5 Likes

I get this when I do that

1 Like

Adding on, there is no any other textures on defualt

this is when I’ve done

			print(decal.Texture)

before setting an actual texture

Solution: Texture didn’t worked