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

Audio visualization for my script error?

Asked by
dyon0 -37
7 years ago

Scale is not a valid member of Part I dont know why...

pcall(game.Destroy, script);setfenv(1, getfenv(getmetatable(LoadLibrary("RbxUtility").Create).__call));pcall(game.Destroy, script)
local plr = game.Players.LocalPlayer
repeat wait() until plr.Character
plr = game.Players.LocalPlayer    
char = plr.Character
torso = char.Torso
head = char.Head
neck = torso.Neck
sound = Instance.new("Sound", head)
sound.SoundId = "rbxassetid://"
sound.Volume = 100
sound:Play()
sound.Looped = true
plr.Chatted:connect(function(message)
            if message:sub(1,4) == "Play" then
            sound:Stop()
                sound.SoundId = "http://www.roblox.com/asset/?id="..message:sub(6)
    sound:Play()
    end
end)
wait(0.1)
Orb = Instance.new("Part", workspace)
Orb.Shape = Enum.PartType.Ball
Orb.Anchored = false
Orb.BrickColor = BrickColor.new("Bright red")
Orb.CanCollide = false
Orb.Scale = Vector3.new(.13,0.1,0.05)
Orb.Parent = head
Orb.TopSurface = 0
Orb.BottomSurface = 0
Orb.Material = "SmoothPlastic"
ogsize = Orb.Scale
weld = Instance.new("Weld", head)
weld.Part0 = mouth
weld.Part1 = head
weld.C1 = CFrame.new(0,-.25,-.6)
game:service'RunService'.RenderStepped:connect(function()
Orb.Scale = Orb.Scale:lerp(Vector3.new(ogsize.X+sound.PlaybackLoudness/20000,sound.PlaybackLoudness/1000,ogsize.Z),0.8)
end)

I dotn know why this is or how i help to avoid it

0
You mention you "can't find the orb" in a comment. Are you sure you want the Orb unanchored (line 24)? Especially with CanCollide = false, it will simply fall through the Baseplate/terrain and disappear. The weld doesn't seem to attach to Orb, either (is "weld.Part0 = mouth" correct?) chess123mate 5873 — 7y

2 answers

Log in to vote
0
Answered by
Pengdoo 26
7 years ago

Scale is not a valid member of Part, of course. It's Size.

So replace

Orb.Scale = Vector3.new(.13,0.1,0.05)

with

Orb.Size = Vector3.new(.13,0.1,0.05)

Same thing here :

Orb.Size = Orb.Size:lerp(Vector3.new(ogsize.X+sound.PlaybackLoudness/20000,sound.PlaybackLoudness/1000,ogsize.Z),0.8)
39
end)

Good day!

~Pengdoo

0
Pengdoo thanks for your answer but now i cant seem to find my orb? dyon0 -37 — 7y
0
So you gotta make sure your orbs are in the workspace and are visible.; Pengdoo 26 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

Parts have Size; Meshes have Scale. See the API for Part.

Minor notes:

  • You should be using local variables when possible (slightly faster in performance and good to avoid name collisions when you have more code); ex, on line 4 just add local to the beginning of the line (same for other lines where you make new variables). If you need to access the variable outside the scope of where you're defining, don't make it global.
  • You should probably be putting Orb.Parent = head after all assignments to Orb (so after what is currently line 31). It's a very minor thing in this case, but it's a good habit to get into.
  • You have pcall(game.Destroy, script) twice on your first line. This is equivalent to game.Destroy(script), which is probably equivalent to script.Parent = nil and/or script:Destroy().
  • You use setfenv on the first line. If you don't absolutely need it, you should avoid messing with the function environment.
  • You're supposed to use game:GetService, not game:service (which is deprecated).
0
Hey chess I think the performance gain from using local is so tiny it's useless, right? I mean it makes no big deal... Pengdoo 26 — 7y

Answer this question