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

What is wrong with this script? Did I type something incorrectly?

I'm really bad at scripting. This is supposed to be a script that causes a plate to turn neon/white when it's touched, then turn back to what it was originally (slate/black) after one second after it isn't being touched. Am I missing something, or did I completely do one of the properties wrong?

local function PlayerTouched(Part)
	local Parent = Part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		script.Parent.Material = "Neon"
		script.Parent.Color = "Institutional white"
	wait(1)
	script.Parent.Material = Slate
	script.Parent.Color = "Black"

script.Parent.Touched:connect(PlayerTouched)

1 comment

0

whats the parts name?

3 answers

✓ Accepted answer

Where's the end statement?

local function PlayerTouched(Part)
    local Parent = Part.Parent
    if game.Players:GetPlayerFromCharacter(Parent) then
        script.Parent.Material = "Neon"
        script.Parent.Color = "Institutional white"
    wait(1)
    script.Parent.Material = Slate
    script.Parent.Color = "Black"
end
end

script.Parent.Touched:connect(PlayerTouched)

1 comment

0

Ohh, I forgot about that. Thanks!

You could also do it like this:

local Plate = script.Parent --Put whatever you name you want instead of plate.

local function SteppedOn(part)
	local Parent = part.Parent
	if game.Players:GetPlayerFromCharacter(Parent) then
		Plate.Material = "Neon"
		Plate.BrickColor = BrickColor.new("Institutional white")
		wait(1)
		Plate.Material = "Slate"
		Plate.BrickColor = BrickColor.new("Black")
		
	end
end

Plate.Touched:Connect(SteppedOn)

2 comments

0

Thanks! I will try to use this one, too.

0

No worries! Hope it helps!

If u don’t want to get spammed or like something?

Local used = false
local function PlayerTouched(Part)
    local Parent = Part.Parent
    if game.Players:GetPlayerFromCharacter(Parent) then
        If used == false then
        used = true
        script.Parent.Material = "Neon"
        script.Parent.Color = "Institutional white"
    wait(1)
    used = false
    script.Parent.Material = Slate
    script.Parent.Color = "Black"
end
end

script.Parent.Touched:connect(PlayerTouched)

1 comment

0

That's the one I'm going to use. Thank you!

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