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

"Soundbrick" script isent working? Need help Broken Script! (im new to this site please help ;-; )

Asked by 6 years ago
Edited 6 years ago

i accidentally deleted the first version so im too lazy to explain it all so heres the quicky


so i made a "SoundBrick" and its supposed to play a sound , then check if the player is five times the position (in x y or z) of the brick , if it is then the song should stop . i think i might've messed up on the coding but remember this is my first time using sound and Positions soooo idk

if you have any more questions on what i did or the placement is or something just ask ,-,


brick = script.Parent.Position.position 
local player = script.Parent.BodyPosition.position 

function onTouch()

script.Sound:Play()
wait(40)
if
    brick < player * 5
    then
    script.Sound.Stop()
    end
end


script.Parent.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by 6 years ago

I see multiple things wrong with this.

First of all, what's up with Position.position? The 'Position' property of a Part is a Vector3, and 'position' isn't a property of a Vector3.

Next thing, you only check the positions one time. Move the variables 'brick' and 'player' into the onTouch function.

Next, replace connect with Connect, as connect is deprecated.

0
wait() is deprecated too, why didn't you correct him? hiimgoodpack 2009 — 6y
0
The global namespace wait() itself is not deprecated. The RBXScriptSignal :wait() is though, and was replaced with :Wait(). PyccknnXakep 1225 — 6y
0
^Like how :connect() was replaced with :Connect(). PyccknnXakep 1225 — 6y
Ad

Answer this question