New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

My keycard scripted door wont play sound and wont do anything else?

Asked by 3 months ago
Edited 3 months ago

I am making a keycard door from prison life 0.6, with my own code. Unfortunately adding the sound thing might have the problem, but I want it to play if the keycard touches the scanner.

Code:

script.Parent.Touched:Connect(function(hit)
 if hit.Parent.Name == "Admissions Keycard" then
  script.Parent.keyscanner.Union.CanCollide = false
  script.Parent.keyscanner.Union.Transparency = 1
  script.Parent.Sound.Playing = true
  wait(2)
  script.Parent.Sound.Playing = false
  script.Parent.keyscanner.Union.CanCollide =  true
  script.Parent.keyscanner.Union.Transparency = 0
 end
end)

Any fixes?

Note I want the "scan" part material to neon, then 2 seconds and go back to smoothplastic.

3 answers

Log in to vote
0
Answered by
Psudar 641 Moderation Voter
3 months ago
Edited 3 months ago

Theres a simple fix to this. According to the API page, the property Playing only indicates if the sound is playing or not. I would guess that you can't actually make it play by changing that variable.

Instead, try doing this:

local Sound = script.Parent:WaitForChild("Sound") --Making sure its loaded in

Sound:Play() --play the sound

wait(2)

Sound:Stop() --stop the sound

Hope this helped.

0
Ad
Log in to vote
0
Answered by 3 months ago

Well actually hit.Parent recognizes it as the 'Handle' part, but you said it was the tools name, which is actually hit.Parent.Parent.

0
Actually thats false information hit is the part that touches the key card and the parent of hit would be the tool Prestory 1390 — 3mo
0
Wait, then what would hit.Parent.Parent be? Cvllapse 30 — 3mo
Log in to vote
0
Answered by 3 months ago
script.Parent.Touched:Connect(function(hit)
 if hit.Parent.Name == "Admissions Keycard" then
  script.Parent.keyscanner.Union.CanCollide = false
  script.Parent.keyscanner.Union.Transparency = 1
  script.Parent.Sound:Play()
  wait(2)
  script.Parent.Sound:Stop()
  script.Parent.keyscanner.Union.CanCollide =  true
  script.Parent.keyscanner.Union.Transparency = 0
 end
end)

Use instead .Playing > :Play() or :Stop()

0
It still wont work, as the door wont work either. kanchoplets 25 — 3mo

Answer this question