#Part Should Glow Only if a Player Is Touching It

1 messages · Page 1 of 1 (latest)

graceful karma
#

Hello, this is my second try on making a script from various tutorials on YouTube, and this time, I have just learned about events. What am I trying to do is that I want the script to make the part glow (changes to a Neon material) only if a player is touching it, and not other objects (e.g. the Baseplate). I am trying to figure out on how to do this, but it seems like I don't know how so maybe I'll seek for help in this forum. I also want it so that the part only glows as long as the player touches it (walking on it), and reverts back to it's default material once the player no longer touches the part.

Here is the script that I made in an attempt to make the thing I wanted above:

local Glow = script.Parent

local PartTouched = false



    Glow.Touched:Connect(function()
    if PartTouched == false then
        PartTouched = true
        Glow.BrickColor = BrickColor.new("Lime green")
        Glow.Material = Enum.Material.Neon
        
    end
    end)
glacial aurora
#

uhh

#

Ever heard of .TouchEnded?

graceful karma
graceful karma
glacial aurora
#

huh?

#

hell you mean its bad?

#

who told you that?

graceful karma
glacial aurora
#

aah

#

no no .Touch and .TouchEnded are only bad when you're trying to do hitboxes

glacial aurora
#

like the jjs hitboxes

glacial aurora
graceful karma
#

okay I understand it

glacial aurora
#

but since thats not ur case (and you also literally just started scripting) just use these 2 events

graceful karma
#

now how do i make it so that it only glows if the player touches it?

and how to shove .TouchEnded into it?

glacial aurora
#

Glow.Touched:Connect(function()
Glow.Material = Enum.Material.Neon
end)

#

Glow.TouchEnded:Connect(function()
Glow.Material = Enum.Material.SmoothPlastic (or whatever material
end)

true gulch
#

mb you was teaching the guy

glacial aurora
#

no worries

graceful karma
#

thanks

i'll try it out soon