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)
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.
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)
removing the text gets rid of error but doesn’t apply decal
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.