I’ve this script I was trying to mess around with in Studio, where the ID I was using on line three was replaced with “ID” before posting here. It’s a server script in ServerScriptStorage:
local Sound = Instance.new("Sound")
Sound.Parent = game.SoundService
Sound.SoundId = "rbxassetid://ID"
local PitchShifter = Instance.new("PitchShiftSoundEffect")
PitchShifter.Parent = game.SoundService
local function ApplyEffect(effectType, value)
if effectType == "shift" then
PitchShifter.Octave = value
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg == '/play' then
game.SoundService.Sound:Play()
end
if string.lower(string.sub(msg, 1, 6)) == "/shift" then
local success, failure = pcall(ApplyEffect, "shift", tonumber(string.sub(msg, 7, string.len(msg))))
if failure then
print("The function call failed. Did you enter in an appropriate value?")
end
end
end)
end)
I’m fully aware that the pcall is probably unnecessary and that the programming style is sloppy but bear with me here. Whenever I attempt to get the sound to play, the sound doesn’t and nothing is shown in the console… I’m left to believe it’s not a syntax error but a logic one that I can’t pinpoint. Not to mention half the time I hit “play” and load into Studio, the chat vanishes on me and I’m unable to bring it up unless I hit stop and play again.
What am I doing wrong here?