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

What wrong with this script?

Asked by 10 years ago
 function onTouched(hit)    
   if hit.Name == "H1" then     
   if script.Parent.Parent.DoorL.Value == false then  
    script.Parent.Parent.DoorL.Value = true  
    wait(60)    
     script.Parent.Parent.DoorL.Value = false  
     end  
     end  
     script.Parent.Parent.Touched:connect(onTouched) 

The H1 is a part ,l place at: Workspace>Model>Model>H1(Part)

0
l need a fix script 7785543 2 — 10y

1 answer

Log in to vote
1
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
10 years ago

On your connection line you have script.Parent.Parent.Touched. Is script.Parent.Parent the part 'H1'? Thescript.Parent.Parent in your code snippet declares which part triggers the touched event. If that was your problem, here is the fix.

local part = game.Workspace.Model.Model.H1 -- Put the location of the part 'H1' here

part.Touched:connect(function(hit)
    if script.Parent.Parent.DoorL.Value == false then
        script.Parent.Parent.DoorL.Value = true
        wait(60)
        script.Parent.Parent.DoorL.Value = false
    end
end)
0
Thanks 7785543 2 — 10y
Ad

Answer this question