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

Can anyone help me on a script that relates to debounce,audio and function (hit)?

Asked by 4 years ago

So basically I'm doing a simple thing where when I land my torso onto the part it will play the audio, which the audio is located in the part called "Mat" Not sure If I'm doing things in reverse but please help anyone

local mat = workspace.Part

local debounce = false

local sc = workspace.mat

local hitm = sc.music

mat.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChild("Humanoid")and debounce == true then

1    hitm:Play()
2 
3        wait(.)
4 
5        debounce = false
6 
7    end
8 
9end)
0
local mat = workspace.Part local debounce = false local sc = workspace.mat local hitm = sc.music mat.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")and debounce == true then hitm:Play() wait(.) debounce = false end end) JerkDerekThe14alt 11 — 4y
0
whats you question? Cats767_99 -68 — 4y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You made debounce = false, whcih is good, but the problem why it doesn't work is because you did and debounce == true, but it's false, so it will never happen. so try this:

01local mat = workspace.Part
02local debounce = false
03local sc = workspace.mat
04local hitm = sc.music
05mat.Parent.Touched:Connect(
06    function(hit)
07        if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
08            debounce = true
09            hitm:Play()
10 
11            wait()
12 
13            hitm.Ended:Wait()
14            debounce = false
15        end
16    end
17)

also, use hitm.Ended:Wait() to wait until the audio ends

0
i would just use... Cats767_99 -68 — 4y
Ad

Answer this question