I put it in StarterCharacterScripts AND StarterPlayerScripts
No, nonono. Thatâs not what I told you to do.
I meant replace workspace.Folder.Obby.Start.BaseStart
with workspace.Folder.Obby.Start:WaitForChild("BaseStart")
And for the audio, you only need to do workspace.Folder.Sounds:WaitForChild("BaseSound")
.
The error is happening because Luau is saying that it will probably wait forever for BaseStart
to exist as a child of workspace
, because it wonât.
The print is just a way to know if the script is actually detecting the touch. Run the game, and touch the part, then check the output. If it says âPart touched!â then the script detects the part touch. If it says âPlaying soundâ then the script is playing the sound. If you still donât hear it, then itâs something with the sound.
local playing = false
print("Script ready")
workspace.Folder.Obby.Start:WaitForChild("BaseStart").Touched:Connect(function(hit)
print("Part touched!")
if hit.Parent:FindFirstChild("Humanoid") and (not playing) then
print("Playing sound")
workspace.Folder.Sounds:WaitForChild("BaseSound"):Play()
playing = true
workspace.Folder.Sounds:WaitForChild("BaseSound").Ended:Wait()
playing = false
end
end)
it says this: Playing sound - Client - LocalScript:8
12:55:08.975 Part touched! (x2) - Client - LocalScript:6
12:55:09.540 Playing sound - Client - LocalScript:8
12:55:10.123 Part touched! - Client - LocalScript:6
12:55:10.123 Playing sound - Client - LocalScript:8
12:55:10.340 Part touched! - Client - LocalScript:6
12:55:10.340 Playing sound - Client - LocalScript:8
12:55:10.656 Infinite yield possible on âWorkspace.Folder.Sounds:WaitForChild(âBaseSoundâ)â - Studio
nothing is playing
I have to go for a little now, but try that.
I would suggest replacing those :WaitForChild()
lines with variables too, sorry I didnât mention that earlier.
local baseStart = workspace.Folder.Obby.Start:WaitForChild("BaseStart")
local baseSound = workspace.Folder.Sounds:WaitForChild("BaseSound")
baseStart.Touched:Connect(function(hit)
...
end)
Script works, just seems like the sound doesnât exist anymore. Did you move it?
Script works just fine for me.
Try sending me the project file with just the scripts and the other items that the script uses, not the entire project.
how are u using the script?? Where did you put it?
It is problem in core(means in Roblox), i seen many people got this error already.
Though its about Gui, not sound.
Can you copy and past the script over?
local playing = false
print("Script ready")
workspace.Folder.Start:WaitForChild("BaseStart").Touched:Connect(function(hit)
print("Part touched!")
if hit.Parent:FindFirstChild("Humanoid") and (not playing) then
print("Playing sound")
workspace.Folder.Sounds:WaitForChild("BaseSound"):Play()
playing = true
workspace.Folder.Sounds:WaitForChild("BaseSound").Ended:Wait()
playing = false
end
end)
Is your volume on?If you just forgot to turn on volume then
relax, lol. it is on full volume. I am applying the script rn
Again, I suggest storing those instances in variables, so the code is much more maintainable.
like this? local playing = false
print("Script ready")
workspace.Folder.Start:WaitForChild("BaseStart").Touched:Connect(function(hit)
print("Part touched!")
if hit.Parent:FindFirstChild("Humanoid") and (not playing) then
print("Playing sound")
workspace.Folder.Sounds:WaitForChild("BaseSound"):Play()
playing = true
workspace.Folder.Sounds:WaitForChild("BaseSound").Ended:Wait()
playing = false
end
end)