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

Need help on this door script?

hey guys i am having trouble with this simple door script

debounce = false

function onTouch(obj)
if debounce then return 
end	
if obj.Parent == nil then return
end
if Players:playerFromCharacter(obj.Parent) == nil
	then return
end
debounce=true
script.Parent.Transparency=0.9
script.Parent.CanCollide= false

wait(2)
script.Parent.Transparency=0
script.Parent.CanCollide=true

debounce = false
end
script.Parent.Touched:connect(onTouch)

i am very new to scipting, 1st week, does it matter what name i put the brick as and also i put this script under the brick i want this to do it to if it matters

1 answer

playerFromCharacter isn't a valid method. I believe your looking for GetPlayerFromCharacter. You also forgot to define "player" on line 8.

debounce = false
players = game.Players --You forgot to define "players"
function onTouch(obj)
if debounce then return 
end 
if obj.Parent == nil then return
end
if players:GetPlayerFromCharacter(obj.Parent) == nil --Changed to GetPlayerFromCharacter
    then return
end
debounce=true
script.Parent.Transparency=0.9
script.Parent.CanCollide= false

wait(2)
script.Parent.Transparency=0
script.Parent.CanCollide=true

debounce = false
end
script.Parent.Touched:connect(onTouch)

2 comments

0

thanks codecakes but what do you mean by define players and what does the last line do the "script.Parent.Touched:connect(onTouch)"...im learning off of roblox wiki but it seems rather vague in explaining thing

0

playerFromCharacter is a member of the Players service. It does the same thing as GetPlayerFromCharacter. Please modify your answer to include this.

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