``Hello there! I have no scripting skills, but I have tried my best, however it will not work. I have a part in the workspace named 'Part'. I am trying to make that part appear when any player is playing music '142376088'. When the player stops playing it, the part will disappear. Could I get some help? Thanks! It could be for the command :music 142376088, however I would prefer it be even on the players personal radio.
Edit: I actually want the part to be moved when the sound is detected, and moved back to its original position when the sound is off
[P.S I am a beginner scripter, only know the basic terms.. excuse my scripting below]
--I have no idea how to make it detect the sound if game.Player.Types(":music 142376088") then game.Workspace.Part.Position(-6, 336.5, -11) --I want this to be where is moved if the music is detected if game."Sound".Off --I want this to be if the sound is turned off then game.Workspace.Part.Position(23727, 336.5, -11) --I want this to be where is moved if music is turned off
Edit #2: With components that chess mentioned. I will change the name 'Part' to 'SpecialPart'. -I also want to use the command :music 142376088. So when it plays, the part is in position and when it is stopped, the part goes back
if musicId == 142376088 then workspace.SpecialPart.CFrame = CFrame.new(-6, 336.5, -11) --Placement when :music 142376088 command is activated sound.Stopped:Connect(function() --when music command is detected off workspace.SpecialPart.CFrame = CFrame.new(23727, 336.5, -11) --Placement when :music 142376088 command is off
Ways of detecting the sound:
if musicId == 142376088 then workspace.SpecialPart.Visible = true end
. You'll also need to connect Sound.Stopped to making it invisible: sound.Stopped:Connect(function() workspace.SpecialPart.Visible = false end)
(of course, musicId
and sound
both need to exit / you need to replace that with whatever variable is already in use by the script.)ChildAdded
), then check to see if it's a sound with the ID you want - this option is otherwise the same as the first.Note: You specified you want workspace.Part
to be modified, but in scripting you need to give these things unique names. Unless you have 0 other things named "Part" in the workspace, Roblox/Lua won't know which one you mean and will just choose the first one it finds.
Note 2; I specified workspace.SpecialPart.Visible = true
, but it would also make sense to change the CanCollide to true/false. Alternatively, your Position idea would also work; here's the syntax: workspace.SpecialPart.CFrame = CFrame.new(-6, 336.5, -11)
(You can also use Position
, but it isn't guaranteed to go to the exact Position you want if there's already Parts there.)