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

Need help on this door script?

Asked by 10 years ago

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

Log in to vote
1
Answered by
Freemium 110
10 years ago

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)
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 namelessassasin 30 — 10y
0
playerFromCharacter is a member of the Players service. It does the same thing as GetPlayerFromCharacter. Please modify your answer to include this. User#11893 186 — 10y
Ad

Answer this question