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

My script needs help, Can you fix it?

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!

1 comment

0

Code block please.

1 answer

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)

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