I’m trying to access a event from a instance using a string, example:
workspace.Part:["GetMass"]()
I tried running it but it gave me an error.
Another example from what I’m trying to do.
local function playAnimations(state)
for _, animationTrack in pairs(animator:GetPlayingAnimationTracks()) do
animationTrack:[state]()
end
end
playAnimations("Play")
playAnimations("Pause")
Instead of using if statements, I could just do that so its faster but I don’t really know how…
local function playAnimations(state)
for _, animationTrack in pairs(animator:GetPlayingAnimationTracks()) do
if state == "Play" then
animationTrack:Play()
elseif state == "Pause" then
animationTrack:Pause()
end
end
playAnimations("Play")
playAnimations("Pause")
local function playAnimations(state)
for _, animationTrack in pairs(animator:GetPlayingAnimationTracks()) do
if state then
animationTrack:Play()
else
animationTrack:Pause()
end
end
end
playAnimations(true)
But I don’t find a reason to check if the state is true or false for every AnimationTrack. I could’ve just do this and the animation would play.
local function playAnimations(state)
for _, animationTrack in pairs(animator:GetPlayingAnimationTracks()) do
animationTrack[state]()
end
end
playAnimations("Play")