✓ Accepted answer
few things wrong with your code
your code:
function onTouched(part)
CrackSound.SoundId = "rbxassetid://131144461"
this.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") and true then -
end
BrickSound:Play()
transparency = 1
CanCollide = false
anchored = false
end
edited code:
local part = script.Parent
local CrackSound = Instance.new("Sound", part)
CrackSound.SoundId = "rbxassetid://131144461"
part.Touched:Connect(
function(hit)
if hit.Parent:FindFirstChild("Humanoid") and true then
CrackSound:Play()
part.Transparency = 1
part.CanCollide = false
part.Anchored = false
end
end
)
Explanation:
You did a few things wrong. function onTouched(part) is not needed as you did this.Touched:Connect(function(part)
CrackSound.SoundId I believe you forgot to reference that in the code, so I did script.Parent.
BrickSound isn't CrackSound?
transparency = 1
CanCollide = false
anchored = false
Remember, Roblox is case sensitive and these are children/properties of the part.
7 comments
I copied another script which played a sound when touched, so that why there are random values.
did it work?
You can use either a named function or an anonymous function. Let people decide. @raid6n
it has an error "cracksound is not a valid member of part"
you didnt really tell us where cracksound is located, so i cant do anything about that
idk what cracksound is...
.... CrackSound.SoundId is in ur code