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

My script needs help, Can you fix it?

Asked by 10 years ago

local Part = script.Parent function onTouch() if(humanoid ~= nil) then --Finds out if it the player or not wait(1) game.Workspace.Part.CanCollide = false game.Workspace.Part.Transparency = .50 game.Workspace.Part.Brickcolor=BrickColor.new("Really black") wait(2) game.Workspace.Part.CanCollide = true game.Workspace.Part.Transparency = 0 game.Workspace.Part.BrickColor = BrickColor.new("Really red") end end Part.Touched:connect(onTouch)

It's a failure!

0
Code block please. Shawnyg 4330 — 10y

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Well, the way you checked to see if it's a player didn't work. It's hard to read your script since it's not in Code Block form, so I can't give much feedback.

sp = script.Parent -- Should lead to the part
on = false

sp.Touched:connect(function(hit) -- Touched event
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and not on then -- Make sure it's a player and the script isn't running already
        on = true -- Sets the value to true so it knows that it's running
        sp.Transparency = .5
        sp.BrickColor = BrickColor.new("Really black")
        sp.CanCOllide = false
        wait(2)
        sp.Transparency = 0
        sp.BrickColor = BrickColor.new("Really red")
        on = false
        sp.CanCollide = true
    end
end)
Ad

Answer this question