How would I be able to add a decal to a certain part's side after it touches a part?

I am trying to make a game that just shows the earth orbiting the sun. And there’s a extremely small chance of it crashing into the sun.

So lets say it crashed; and I wanted to add a texture onto a specific side of the texture. For this current situation I want it to apply it on the side that crashed.

I don’t want to and don’t know how to use RayCast so I am using TouchInterest due to it being good enough for this certain occasion. How would I be able to add this? (if raycast is the only way ill probably learn how it works)

Current Script for the Earth Exploding (children of sun)

function onTouched(hit)
	Sun = Instance.new("Explosion")
	Sun.BlastRadius = 20
	Sun.BlastPressure = 200000
	Sun.Position = script.Parent.Position
	Sun.Parent = game.Workspace
	script.Parent.Transparency = 0
	workspace.Planets.Model.Earth.Transparency = 1
	workspace.Planets.Model.Earth.CanTouch = false
	
	end

script.Parent.Touched:connect(onTouched)

Game: Planet Orbiting Test - Roblox

Pretty simple. Like how you made the Explosion instance, make a new Instance called “Texture” or “Decal”. For this instance, we’ll do Texture.

local Texture = Instance.new("Texture")

Now, if you go to the library of properties for Texture, you can see that there’s the Face property. Since this is actually an Enum.NormalId, you’ll need to look at what properties are available for it. Which should look like this.

local Texture = Instance.new("Texture")

Texture.Face = Enum.NormalId.Top

And then with that, you can put this little bit of code inside of the specific part’s script. And then it should be work! Let me know if you have any troubles.

1 Like

Doesn’t do anything for some reason.

Modified script:

function onTouched(hit)
	script.Parent.Touched = Instance.new("Decal")
	workspace.Planets.Model.Earth.Decal.Face = 1
	workspace.Planets.Model.Earth.Decal.Texture = 1951256376
	
end

script.Parent.Touched:connect(onTouched)

Instead of 1, it’s supposed to be Enum.NormalId. You should check out the links that’s embedded within the words.

1 Like

Also, Texture is expecting a string. So instead do "rbxassetid://1951256376"

1 Like
function onTouched(hit)
	script.Parent.Touched = Instance.new("Decal")
	workspace.Planets.Model.Earth.Decal.Enum.NormalId = Top
	workspace.Planets.Model.Earth.Decal.Texture = rbxassetid://1951256376
	
end

script.Parent.Touched:connect(onTouched)

Screenshot_1
removing the text gets rid of error but doesn’t apply decal

It’s expecting a string. Strings are anything that inside quotation marks.

Like this:

"Hello, I'm a string!"

So when you just removed the quotations that was already inside of my text, it changed it from a string to a mathematical equation. Hence the error.

1 Like

Did that already, didn’t work.

workspace.Planets.Model.Earth.Decal.Enum.NormalId = Top

Change it to

workspace.Planets.Model.Earth.Decal.Face = Enum.NormalId.Top
1 Like

Still didn’t apply decal, yet no errors.

I’m just gonna use your code that you provided and change it to where it makes sense…

function onTouched(hit)
	local NewDecal = Instance.new("Decal")

	NewDecal.Face = Enum.NormalId.Top
	NewDecal.Texture = "rbxassetid://1951256376"
	NewDecal.Parent = workspace.Planets.Model.Earth

You need a walkthrough with what’s going on in this script?

2 Likes

I can read the code, its very good yet it doesn’t work.

function onTouched(hit)
	local NewDecal = Instance.new("Decal")

	NewDecal.Face = Enum.NormalId.Top
	NewDecal.Texture = "rbxassetid://1951256376"
	NewDecal.Parent = workspace.Planets.Model.Earth
end
script.Parent.Touched:connect(onTouched)

Even tried without TouchInterest or end (without end it provided a error) but still doesn’t apply texture.

Is Earth a part or any type of BasePart?

1 Like

The earth is a MeshPart. I don’t see how that would change anything tho. Since applying normal decals work. Would it having SurfaceAppearance change anything?

I have an idea that I can easily implement; Change the current texture of the SurfaceAppearance to something of a “destroyed” Earth and apply it when the Earth touches the sun. I am gonna try if it works and I’ll update you if it doesn’t.

Sounds like a better way of doing it, instead of how I’m doing it.

1 Like

ok i just give up thanks for the help

what i did: made the part invisible after it touches the sun