I’m trying to make a block that changed the music that you hear when you touch it. My only issue is when I touch it, nothing happens. My print script doesn’t send anything to my output.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”)then
workspace.Music.SoundId = (“rbxassetid://2010551278”)
print(“Hit!”)
end
end)
Also is workspace.Music.SoundId = (“rbxassetid://2010551278”) correct?
local debounce
script.Parent.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorOfClass("Model")
if character then
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then
return
end
debounce = true
workspace.Music.SoundId = "rbxassetid://2010551278"
print("Checkpoint")
wait(5) -- change cooldown
debounce = false
end
end)
Confirm that your script is directly parented to the part.
Spacing does not make a difference there, I tested it myself. The function has proven to not fire at all after touching. I’m certain that the script’s parented part is incorrectly set.
Additional checks
Are you in a TC?
If so, are you using collaborative editing?
Otherwise, could you provide full detail of the script’s ancestry and the target BasePart?
After thinking, is this a Script, or a LocalScript? If it is a LocalScript, then try moving it into StarterPlayerScripts, or anywhere where it will run.
Since the part is in workspace, consider naming the directory(ancestry) to the target part from StarterPlayerScripts using workspace.[YOUR PART NAME HERE].[OPTIONAL SUBSEQUENT PARTS].
In terms of cross-fading, it is something I have trying to come up with a module. The theory goes along the lines of Track A plays until remaining X seconds and starting the Track B. At the same time, play tweening of Track A out and Track B in.