Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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)
0
whats the parts name? ranger176947 14 — 5y

3 answers

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago
Edited 5 years ago

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)
0
Ohh, I forgot about that. Thanks! SheriffTaco 13 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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)
0
Thanks! I will try to use this one, too. SheriffTaco 13 — 5y
0
No worries! Hope it helps! ranger176947 14 — 5y
Log in to vote
0
Answered by 5 years ago

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)
0
That's the one I'm going to use. Thank you! SheriffTaco 13 — 5y

Answer this question